$this
<?phpクラス DSL_Builder {保護された $ parent ;保護された $オブジェクト ;パブリック関数 __construct( $ parent 、 $ object ){$ this- > parent = $ parent ;$ this- > object = $ object ;}パブリック関数 __get( $ property ){switch ( $ property ){ケース 「終了」 :$ this- > parentを返しますか? $ this- > parent: $ this- > object;ケース 「オブジェクト」 :$ this- > $ propertyを 返し ます 。デフォルト :新しい Core_MissingPropertyException( $ property );}}public function __set( $ property 、 $ value ){ throw new Core_ReadOnlyObjectException( $ this ); }パブリック関数 __isset( $ property ){switch ( $ property ){ケース 「オブジェクト」 :return isset ( $ this- > $ property );デフォルト :falseを返します 。}}public function __unset( $ property ){ throw新しい Core_ReadOnlyObjectException( $ this ); }パブリック関数 __call( $ method 、 $ args ){method_exists( $ this-> object、 $ method )?call_user_func_array( array ( $ this-> object、 $ method )、 $ args ):$ this-> object-> $ method = $ args [ 0 ];$ thisを 返します。}}?>
$object
end
<?phpクラス Config_DSL_Builder は DSL_Builderを拡張します{public function __construct(Config_DSL_Builder $ parent = null 、 stdClass $ object = null ){parent :: __構文( $ parent 、Core :: if_null( $ object 、 new stdClass ()));}public function load( $ file ){ob_start();インクルード ( $ file );ob_end_clean();$ thisを 返します。}public function begin( $ name ){return new Config_DSL_Builder( $ this 、 $ this-> object-> $ name = new stdClass ());}パブリック関数 __get( $ property ){return (strpos( $ property 、 'begin_' )=== 0 )?$ this-> begin(substr( $ property 、 6 )):親:: __ get( $ property );}パブリック関数 __call( $ method 、 $ args ){$ this-> object-> $ method = $ args [ 0 ];$ thisを 返します。}}?>
config.php
<?php$ this- >begin_db->dsn( 'mysql://ユーザー:パスワード@ localhost / db' )->終わり->begin_cache->dsn( 'ダミー://' )->default_timeout( 300 )->タイムアウト( 配列 ('front / index' => 300 、'news / most_popular' => 300 、'ニュース/カテゴリ' => 300 ))->終わり->begin_site->begin_from->top_limit( 7 )->終わり->begin_news->most_popular_limit( 5 )->終わり->終わり;?>
<?php$ config = Config_DSL :: Builder()-> load( 'config.php' );?>
<?phpWS_REST_DSL ::アプリケーション()->media_type( 'html' 、 'text / html' 、 true )->media_type( 'rss' 、 'application / xhtml + xml' )->begin_resource( 'gallery' 、 'App.Photo.Gallery' 、 'galleries / {id:\ d +}' )->for_format( 'html' )->get_for( '{page_no:\ d +}' 、 'index' )->post_for( 'vote' 、 'vote' )->インデックス()->終わり->終わり->begin_resource( 'index' 、 'App.Photo.Index' )->for_format( 'rss' )->get( 'index_rss' )->get_for( 'top' 、 'top_rss' )->終わり->for_format( 'html' )->get_for( '{page_no:\ d +}' 、 'index' )->インデックス()->終わり->終わり->終わり;?>
<?phpパブリック関数インデックス( $ page_no = 1 ){$ pager = Data_Pagination :: pager( $ this-> db-> photo- > galleries-> count()、 $ page_no 、self :: PAGE_LIMIT);$ this-> html( 'index' )->を返します( 配列 ('top' => $ this-> db-> photo-> galleries-> most_important()-> select()、'pager' => $ pager 、'ギャラリー' => $ this-> db-> photo-> galleries->公開済み()->paginate_with( $ pager )->select()));}?>
DSL_Builder
<?phpService_Google_AdWords_DSL ::スクリプト()->for_campaign( $ campaign_id )->for_ad_group( $ group_id )->for_each( 'text' 、 'keyword1' 、 'keyword2' 、 'keyword3' )->add_keyword_criteria()->バインド( 'text' )->終わり->終わり->add_ad()->( 'headline' 、 'headline' 、'displayUrl' 、 'www.techart.ru' 、'destinationUrl' 、 'http://www.techart.ru/' 、'description1' 、 'desc1' 、'description2' 、 'desc2' )->形式( 「作成された広告」 )->終わり->終わり->終わり->for_each_campaign()->形式( "キャンペーン:%d、%s \ n" 、 'campaign.id' 、 'campaign.name' )->ダンプ( 'campaign' )->for_each_ad_group()->形式( "広告グループ:%d、%s \ n" 、 'ad_group.id' 、 'ad_group.name' )->for_each_criteria()->形式( "基準:%d、%s \ n" 、 'criteria.id' 、 'criteria.text' )->終わり->終わり->終わり->終わり->run_for(Service_Google_AdWords ::クライアント()->useragent( 'ユーザーエージェント' )->メール( 'email@domain.com' ));?>
Source: https://habr.com/ru/post/J82715/More articles:トラベルカプセルDelphiの汎用インターフェイス無料の有料ソフトウェアSpectreは、学生IGF 2010の10人の受賞者の1人です。NTT DoCoMoはLTEを搭載した携帯電話を準備していますFacebookはPHPコンパイラを作成していますか?世界に笑顔を!2月1日からの新しいビルドOpera 10.50(3218/8215/6204)コンピューターのテレビ空撮サービスインターフェイスAll Articles