idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
19,700
public function addLogger ( $ logger , $ format = 'CLF' ) { if ( defined ( 'GuzzleHttp\Subscriber\Log\Formatter::' . $ format ) ) { $ format = constant ( 'GuzzleHttp\Subscriber\Log\Formatter::' . $ format ) ; } $ subscriber = new LogSubscriber ( $ logger , $ format ) ; $ this -> guzzleClient -> getEmitter ( ) -> attach ( $ subscriber ) ; }
Add a logger to the guzzle client .
19,701
public function addFile ( $ filepath , $ key = 'file' ) { $ this -> options = array_merge_recursive ( $ this -> options , [ 'body' => [ $ key => fopen ( $ filepath , 'r' ) , ] , ] ) ; return $ this ; }
Add a file to the request .
19,702
public function getUrl ( ) { if ( ! $ this -> url ) { throw new InvalidUrlException ( ) ; } $ url = $ this -> url ; if ( ! parse_url ( $ this -> url , PHP_URL_SCHEME ) ) { $ url = $ this -> getProtocol ( ) . $ url ; } return $ url ; }
Getter for the url will append protocol if one does not exist .
19,703
public function getOptions ( $ options ) { $ options = array_merge ( [ 'verify' => $ this -> verify ] , $ options ) ; if ( $ this -> async ) { $ options = array_merge ( [ 'future' => true ] , $ options ) ; } return array_merge_recursive ( $ this -> options , $ options ) ; }
Getter for options .
19,704
protected function send ( $ function , array $ options = [ ] ) { $ guzzle = $ this -> getGuzzleClient ( ) ; $ url = $ this -> getUrl ( ) ; $ options = $ this -> getOptions ( $ options ) ; $ this -> initialize ( ) ; return $ guzzle -> $ function ( $ url , $ options ) ; }
Send the request using guzzle .
19,705
protected function addRetrySubscriber ( GuzzleClient $ guzzle ) { $ retry = new RetrySubscriber ( [ 'filter' => RetrySubscriber :: createStatusFilter ( $ this -> retryOn ) , 'delay' => function ( $ number , $ event ) { return $ this -> retryDelay ; } , 'max' => $ this -> retry , ] ) ; $ guzzle -> getEmitter ( ) -> attach ( $ retry ) ; return $ guzzle ; }
Add the retry subscriber to the guzzle client .
19,706
protected function initialize ( ) { $ this -> url = '' ; $ this -> options = [ ] ; $ this -> secure = array_get ( $ this -> config , 'secure' , true ) ; $ this -> retryOn = array_get ( $ this -> config , 'retry.on' , [ 500 , 502 , 503 , 504 ] ) ; $ this -> retryDelay = array_get ( $ this -> config , 'retry.delay' , 10 ) ; $ this -> retry = array_get ( $ this -> config , 'retry.times' , 5 ) ; $ this -> verify = array_get ( $ this -> config , 'verify' , true ) ; $ this -> async = array_get ( $ this -> config , 'async' , false ) ; }
Resets all variables to default values required if using the same instance for multiple requests .
19,707
private function adminModules ( ) { $ return = [ ] ; foreach ( $ this -> app [ 'config' ] -> get ( 'modules.all' ) as $ module ) { $ controller = '\\app\\' . $ module . '\\Controller' ; if ( ! class_exists ( $ controller ) ) { continue ; } if ( property_exists ( $ controller , 'scaffoldAdmin' ) || property_exists ( $ controller , 'hasAdminView' ) ) { $ moduleInfo = [ 'name' => $ module , 'title' => Inflector :: get ( ) -> titleize ( $ module ) , ] ; if ( property_exists ( $ controller , 'properties' ) ) { $ moduleInfo = array_replace ( $ moduleInfo , $ controller :: $ properties ) ; } $ return [ ] = $ moduleInfo ; } } return $ return ; }
Returns a list of modules with admin sections .
19,708
private function fetchModelInfo ( $ module , $ model = false ) { $ controller = '\\app\\' . $ module . '\\Controller' ; $ controllerObj = new $ controller ( $ this -> app ) ; $ properties = $ controller :: $ properties ; $ availableModels = $ this -> models ( $ controllerObj ) ; if ( ! $ model ) { if ( count ( $ availableModels ) == 1 ) { return reset ( $ availableModels ) ; } else { $ model = U :: array_value ( $ properties , 'defaultModel' ) ; } } $ inflector = Inflector :: get ( ) ; $ modelName = $ inflector -> singularize ( $ inflector -> camelize ( $ model ) ) ; return U :: array_value ( $ availableModels , $ modelName ) ; }
Takes the pluralized model name from the route and gets info about the model .
19,709
private function models ( $ controller ) { $ properties = $ controller :: $ properties ; $ module = $ this -> name ( $ controller ) ; $ models = [ ] ; foreach ( ( array ) U :: array_value ( $ properties , 'models' ) as $ model ) { $ modelClassName = '\\app\\' . $ module . '\\models\\' . $ model ; $ info = $ modelClassName :: metadata ( ) ; $ models [ $ model ] = array_replace ( $ info , [ 'route_base' => '/' . $ module . '/' . $ info [ 'plural_key' ] , ] ) ; } return $ models ; }
Fetches the models for a given controller .
19,710
protected function applyScopes ( QueryBuilder $ query , Model $ model , $ ignoreScopes = [ ] ) { if ( in_array ( '*' , $ ignoreScopes ) ) { return ; } $ class = get_called_class ( ) ; $ scopes = Arr :: get ( static :: $ scopes , $ class , [ ] ) ; foreach ( $ scopes as $ sid => $ scope ) { if ( ! in_array ( $ sid , $ ignoreScopes ) ) { $ scope -> apply ( $ query , $ model ) ; } } }
Apply scopes in query .
19,711
public function setGroupId ( $ groupId ) { $ this -> groupId = ( int ) $ groupId ? : null ; if ( $ this -> group && $ this -> group -> id != $ this -> groupId ) { $ this -> group = null ; } return $ this ; }
Set group - id
19,712
public function getUri ( $ locale = null ) { if ( empty ( $ locale ) ) { $ locale = $ this -> getLocale ( ) ; } return '/app/' . $ locale . '/user/view/' . rawurlencode ( $ this -> displayName ) ; }
Get url for view user
19,713
public function getContent ( $ index = null , $ raw = false ) { if ( null === $ index ) { return ( bool ) $ raw ? $ this -> cbuff : join ( '' , $ this -> cbuff ) ; } if ( isset ( $ this -> cbuff [ ( int ) $ index ] ) ) { return $ this -> cbuff [ ( int ) $ index ] ; } throw new \ OutOfBoundsException ( sprintf ( 'No content at buffer %d or empty buffer.' , ( int ) $ index ) ) ; }
Get the contents .
19,714
public function build ( ) { $ file = rtrim ( $ this -> cacheDir , '/' ) . '/' . $ this -> getFilename ( ) ; $ mapFile = $ file . '.map' ; $ cache = new PuliResourceCollectionCache ( $ file , $ this -> isDebug ( ) ) ; $ resources = $ this -> resourceFinder -> findByType ( $ this -> getType ( ) ) ; if ( ! $ cache -> isFresh ( $ resources ) ) { $ resolvedResources = $ this -> resourceResolver -> resolve ( $ resources ) ; $ mappedContent = $ this -> contentBuilder -> build ( $ this -> getFilename ( ) , $ resolvedResources , array ( $ this , 'sanitizePath' ) , array ( $ this , 'prefixContent' ) ) ; $ cache -> write ( $ mappedContent -> getContent ( ) ) ; file_put_contents ( $ mapFile , $ mappedContent -> getMap ( ) ) ; if ( ! $ this -> debug ) { $ this -> compressor -> compressFile ( $ file ) ; } } return new MappedAsset ( $ file , $ mapFile ) ; }
Get all javascripts for the given section .
19,715
public function showPosts ( $ pagenumber = 1 ) { $ posts = $ this -> post -> findAll ( ) ; $ viewParamaters = array ( 'global' => $ this -> global , 'posts' => $ posts , 'pageNumber' => $ pagenumber ) ; return \ View :: make ( $ this -> theme . '.posts' , $ viewParamaters ) ; }
Show all of the posts .
19,716
public function showPost ( $ category , $ postName ) { if ( ! $ this -> post -> exists ( $ category , $ postName ) ) { return \ Response :: view ( $ this -> theme . '.404' , array ( 'global' => $ this -> global ) , 404 ) ; } $ post = $ this -> post -> getPost ( $ category , $ postName ) ; $ category = $ this -> category -> getCategory ( $ category ) ; $ viewParamaters = array ( 'post' => $ post , 'global' => $ this -> global , 'category' => $ category ) ; return \ View :: make ( $ this -> theme . '.post' , $ viewParamaters ) ; }
Show a single post .
19,717
protected function process_file ( $ file_override = false ) { $ clean_room = function ( $ __file_name , array $ __data ) { extract ( $ __data , EXTR_REFS ) ; ob_start ( ) ; try { include $ __file_name ; } catch ( \ Exception $ e ) { ob_end_clean ( ) ; throw $ e ; } return ob_get_clean ( ) ; } ; return $ clean_room ( $ file_override ? : $ this -> file_name , $ this -> get_data ( ) ) ; }
Captures the output that is generated when a view is included . The view data will be extracted to make local variables . This method is static to prevent object scope resolution .
19,718
protected function get_data ( $ scope = 'all' ) { $ clean_it = function ( $ data , $ rules , $ auto_filter ) { foreach ( $ data as $ key => & $ value ) { $ filter = array_key_exists ( $ key , $ rules ) ? $ rules [ $ key ] : null ; $ filter = is_null ( $ filter ) ? $ auto_filter : $ filter ; $ value = $ filter ? \ Security :: clean ( $ value , null , 'security.output_filter' ) : $ value ; } return $ data ; } ; $ data = array ( ) ; if ( ! empty ( $ this -> data ) and ( $ scope === 'all' or $ scope === 'local' ) ) { $ data += $ clean_it ( $ this -> data , $ this -> local_filter , $ this -> auto_filter ) ; } if ( ! empty ( static :: $ global_data ) and ( $ scope === 'all' or $ scope === 'global' ) ) { $ data += $ clean_it ( static :: $ global_data , static :: $ global_filter , $ this -> auto_filter ) ; } return $ data ; }
Retrieves all the data both local and global . It filters the data if necessary .
19,719
public function auto_filter ( $ filter = true ) { if ( func_num_args ( ) == 0 ) { return $ this -> auto_filter ; } $ this -> auto_filter = $ filter ; return $ this ; }
Sets whether to filter the data or not .
19,720
public function set_filename ( $ file ) { \ Finder :: instance ( ) -> flash ( $ this -> request_paths ) ; if ( ( $ path = \ Finder :: search ( 'views' , $ file , '.' . $ this -> extension , false , false ) ) === false ) { throw new \ FuelException ( 'The requested view could not be found: ' . \ Fuel :: clean_path ( $ file ) ) ; } $ this -> file_name = $ path ; return $ this ; }
Sets the view filename .
19,721
public function & get ( $ key = null , $ default = null ) { if ( func_num_args ( ) === 0 or $ key === null ) { return $ this -> data ; } elseif ( array_key_exists ( $ key , $ this -> data ) ) { return $ this -> data [ $ key ] ; } elseif ( array_key_exists ( $ key , static :: $ global_data ) ) { return static :: $ global_data [ $ key ] ; } if ( is_null ( $ default ) and func_num_args ( ) === 1 ) { throw new \ OutOfBoundsException ( 'View variable is not set: ' . $ key ) ; } else { $ default = \ Fuel :: value ( $ default ) ; return $ default ; } }
Searches for the given variable and returns its value . Local variables will be returned before global variables .
19,722
public function render ( $ file = null ) { if ( class_exists ( 'Request' , false ) ) { $ current_request = \ Request :: active ( ) ; \ Request :: active ( $ this -> active_request ) ; } if ( $ this -> active_language ) { $ current_language = \ Config :: get ( 'language' , 'en' ) ; \ Config :: set ( 'language' , $ this -> active_language ) ; } if ( $ file !== null ) { $ this -> set_filename ( $ file ) ; } if ( empty ( $ this -> file_name ) ) { throw new \ FuelException ( 'You must set the file to use within your view before rendering' ) ; } $ return = $ this -> process_file ( ) ; $ this -> active_language and \ Config :: set ( 'language' , $ current_language ) ; if ( isset ( $ current_request ) ) { \ Request :: active ( $ current_request ) ; } return $ return ; }
Renders the view object to a string . Global and local data are merged and extracted to create local variables within the view file .
19,723
public function addCss ( $ css ) { if ( ! is_array ( $ css ) ) { $ css = preg_replace ( '/[ ]+/' , ' ' , $ css ) ; $ css = explode ( ' ' , $ css ) ; } foreach ( $ css as $ class ) { $ this -> css [ $ class ] = $ class ; } }
Add one or more css classes to the html object . Accepts single value a string of space separated classnames or an array of classnames .
19,724
public function isHidden ( int $ state = null ) { $ attrib = 'hidden' ; if ( empty ( $ state ) ) { return $ this -> checkAttribute ( $ attrib ) ; } if ( $ state == 0 ) { $ this -> removeAttribute ( $ attrib ) ; } else { $ this -> addAttribute ( $ attrib ) ; } }
Hidden attribute setter and checker
19,725
public function build ( ) : string { $ html_attr = [ ] ; if ( ! $ this -> element ) { $ this -> element = strtolower ( ( new \ ReflectionClass ( $ this ) ) -> getShortName ( ) ) ; } if ( ! empty ( $ this -> id ) ) { $ html_attr [ 'id' ] = $ this -> id ; } if ( ! empty ( $ this -> name ) ) { $ html_attr [ 'name' ] = $ this -> name ; } if ( $ this -> css ) { $ this -> css = array_unique ( $ this -> css ) ; $ html_attr [ 'class' ] = implode ( ' ' , $ this -> css ) ; } if ( $ this -> style ) { $ styles = [ ] ; foreach ( $ this -> style as $ name => $ val ) { $ styles [ ] = $ name . ': ' . $ val ; } $ html_attr [ 'style' ] = implode ( '; ' , $ styles ) ; } if ( $ this -> event ) { foreach ( $ this -> event as $ event => $ val ) { $ html_attr [ $ event ] = $ val ; } } if ( $ this -> data ) { foreach ( $ this -> data as $ attr => $ val ) { $ html_attr [ 'data-' . $ attr ] = $ val ; } } if ( $ this -> aria ) { foreach ( $ this -> aria as $ attr => $ val ) { $ html_attr [ 'aria-' . $ attr ] = $ val ; } } if ( $ this -> attribute ) { foreach ( $ this -> attribute as $ attr => $ val ) { $ html_attr [ $ attr ] = $ val ; } } $ tmp_attr = [ ] ; foreach ( $ html_attr as $ name => $ val ) { $ tmp_attr [ ] = $ val === false ? $ name : $ name . ( strpos ( $ name , 'data' ) === false ? '="' . $ val . '"' : '=\'' . $ val . '\'' ) ; } $ html_attr = implode ( ' ' , $ tmp_attr ) ; switch ( $ this -> element ) { case 'input' : case 'meta' : case 'img' : case 'link' : $ html = '<' . $ this -> element . ( $ html_attr ? ' ' . $ html_attr : '' ) . '>' ; break ; default : $ html = '<' . $ this -> element . ( $ html_attr ? ' ' . $ html_attr : '' ) . '>' . $ this -> inner . '</' . $ this -> element . '>' ; break ; } return $ html ; }
Builds and returns the html code created out of all set attributes and their values
19,726
public function filterByYear ( $ year = null , $ comparison = null ) { if ( is_array ( $ year ) ) { $ useMinMax = false ; if ( isset ( $ year [ 'min' ] ) ) { $ this -> addUsingAlias ( ReferenceTableMap :: COL_YEAR , $ year [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ year [ 'max' ] ) ) { $ this -> addUsingAlias ( ReferenceTableMap :: COL_YEAR , $ year [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( ReferenceTableMap :: COL_YEAR , $ year , $ comparison ) ; }
Filter the query on the year column
19,727
public function filterByPublisher ( $ publisher = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ publisher ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ publisher ) ) { $ publisher = str_replace ( '*' , '%' , $ publisher ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( ReferenceTableMap :: COL_PUBLISHER , $ publisher , $ comparison ) ; }
Filter the query on the publisher column
19,728
public function filterByJournal ( $ journal = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ journal ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ journal ) ) { $ journal = str_replace ( '*' , '%' , $ journal ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( ReferenceTableMap :: COL_JOURNAL , $ journal , $ comparison ) ; }
Filter the query on the journal column
19,729
public function filterByNumber ( $ number = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ number ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ number ) ) { $ number = str_replace ( '*' , '%' , $ number ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( ReferenceTableMap :: COL_NUMBER , $ number , $ comparison ) ; }
Filter the query on the number column
19,730
public function filterBySchool ( $ school = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ school ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ school ) ) { $ school = str_replace ( '*' , '%' , $ school ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( ReferenceTableMap :: COL_SCHOOL , $ school , $ comparison ) ; }
Filter the query on the school column
19,731
public function filterByEdition ( $ edition = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ edition ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ edition ) ) { $ edition = str_replace ( '*' , '%' , $ edition ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( ReferenceTableMap :: COL_EDITION , $ edition , $ comparison ) ; }
Filter the query on the edition column
19,732
public function filterByVolume ( $ volume = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ volume ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ volume ) ) { $ volume = str_replace ( '*' , '%' , $ volume ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( ReferenceTableMap :: COL_VOLUME , $ volume , $ comparison ) ; }
Filter the query on the volume column
19,733
public function filterByAddress ( $ address = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ address ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ address ) ) { $ address = str_replace ( '*' , '%' , $ address ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( ReferenceTableMap :: COL_ADDRESS , $ address , $ comparison ) ; }
Filter the query on the address column
19,734
public function filterByEditor ( $ editor = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ editor ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ editor ) ) { $ editor = str_replace ( '*' , '%' , $ editor ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( ReferenceTableMap :: COL_EDITOR , $ editor , $ comparison ) ; }
Filter the query on the editor column
19,735
public function filterByHowpublished ( $ howpublished = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ howpublished ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ howpublished ) ) { $ howpublished = str_replace ( '*' , '%' , $ howpublished ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( ReferenceTableMap :: COL_HOWPUBLISHED , $ howpublished , $ comparison ) ; }
Filter the query on the howpublished column
19,736
public function filterByNote ( $ note = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ note ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ note ) ) { $ note = str_replace ( '*' , '%' , $ note ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( ReferenceTableMap :: COL_NOTE , $ note , $ comparison ) ; }
Filter the query on the note column
19,737
public function filterByBooktitle ( $ booktitle = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ booktitle ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ booktitle ) ) { $ booktitle = str_replace ( '*' , '%' , $ booktitle ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( ReferenceTableMap :: COL_BOOKTITLE , $ booktitle , $ comparison ) ; }
Filter the query on the booktitle column
19,738
public function filterByLastchecked ( $ lastchecked = null , $ comparison = null ) { if ( is_array ( $ lastchecked ) ) { $ useMinMax = false ; if ( isset ( $ lastchecked [ 'min' ] ) ) { $ this -> addUsingAlias ( ReferenceTableMap :: COL_LASTCHECKED , $ lastchecked [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ lastchecked [ 'max' ] ) ) { $ this -> addUsingAlias ( ReferenceTableMap :: COL_LASTCHECKED , $ lastchecked [ 'max' ] , Criteria :: LESS_EQUAL ) ; $ useMinMax = true ; } if ( $ useMinMax ) { return $ this ; } if ( null === $ comparison ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( ReferenceTableMap :: COL_LASTCHECKED , $ lastchecked , $ comparison ) ; }
Filter the query on the lastchecked column
19,739
public function filterByManaged ( $ managed = null , $ comparison = null ) { if ( is_string ( $ managed ) ) { $ managed = in_array ( strtolower ( $ managed ) , array ( 'false' , 'off' , '-' , 'no' , 'n' , '0' , '' ) ) ? false : true ; } return $ this -> addUsingAlias ( ReferenceTableMap :: COL_MANAGED , $ managed , $ comparison ) ; }
Filter the query on the managed column
19,740
public function useSkillReferenceQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinSkillReference ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'SkillReference' , '\gossi\trixionary\model\SkillReferenceQuery' ) ; }
Use the SkillReference relation SkillReference object
19,741
public function filterBySkill ( $ skill , $ comparison = Criteria :: EQUAL ) { return $ this -> useSkillReferenceQuery ( ) -> filterBySkill ( $ skill , $ comparison ) -> endUse ( ) ; }
Filter the query by a related Skill object using the kk_trixionary_skill_reference table as cross reference
19,742
public function createProject ( $ packageName , $ packageVersion , $ outputFolder ) { $ this -> runCommand ( 'create-project --prefer-dist ' . $ packageName . ' ' . $ outputFolder . ' "' . $ packageVersion . '"' ) ; return $ this ; }
Composer create - project .
19,743
protected function find ( ) { if ( ! File :: exists ( $ this -> workingPath . '/composer.phar' ) ) { return 'composer' ; } $ binary = ProcessUtils :: escapeArgument ( ( new PhpExecutableFinder ) -> find ( false ) ) ; if ( defined ( 'HHVM_VERSION' ) ) { $ binary .= ' --php' ; } return "{$binary} composer.phar" ; }
Find composer .
19,744
protected function runCommand ( $ command ) { $ process = $ this -> getProcess ( ) ; $ process -> setCommandLine ( trim ( $ this -> find ( ) . ' ' . $ command ) ) ; $ process -> run ( ) ; return $ this ; }
Run composer command .
19,745
public function getThemeInfo ( $ key ) { if ( null === $ this -> theme ) { $ this -> theme = wp_get_theme ( ) ; } $ headers = [ 'name' => 'Name' , 'description' => 'Description' , 'author' => 'Author' , 'authoruri' => 'AuthorURI' , 'themeuri' => 'ThemeURI' , 'version' => 'Version' , 'status' => 'Status' , 'tags' => 'Tags' , 'textdomain' => 'TextDomain' ] ; $ key = strtolower ( $ key ) ; if ( isset ( $ headers [ $ key ] ) ) { return $ this -> theme -> get ( $ headers [ $ key ] ) ; } return false ; }
Retrieves theme information
19,746
public function getThemeOption ( $ key , $ default = null ) { $ options = get_option ( 'novusopress_theme_options' ) ? : [ ] ; if ( array_key_exists ( $ key , $ options ) ) { return apply_filters ( sprintf ( 'novusopress_theme_options_%s' , $ key ) , $ options [ $ key ] ) ; } $ defaults = $ this -> getThemeDefaultOptions ( ) ; if ( array_key_exists ( $ key , $ defaults ) ) { return apply_filters ( sprintf ( 'novusopress_theme_options_%s' , $ key ) , $ defaults [ $ key ] ) ; } return $ default ; }
Retrieves theme option
19,747
public function addThemeSupports ( ) { load_theme_textdomain ( 'novusopress' , $ this -> paths -> getBaseLanguageDir ( ) ) ; add_theme_support ( 'title-tag' ) ; add_theme_support ( 'automatic-feed-links' ) ; add_theme_support ( 'post-thumbnails' ) ; add_theme_support ( 'html5' , [ 'search-form' , 'comment-form' , 'comment-list' , 'gallery' , 'caption' ] ) ; register_nav_menus ( [ 'main-menu' => __ ( 'Main Menu' , 'novusopress' ) ] ) ; if ( $ this -> getThemeOption ( 'clean_document_head' ) ) { $ this -> cleanDocumentHead ( ) ; } if ( file_exists ( sprintf ( '%s/css/editor-style.css' , $ this -> paths -> getThemeAssetsDir ( ) ) ) ) { add_editor_style ( 'assets/css/editor-style.css' ) ; } }
Enables theme supports
19,748
public function registerWidgets ( ) { $ this -> registerWidget ( __ ( 'Header Widget Area' , 'novusopress' ) , 'header' , 'widgets' ) ; $ this -> registerWidget ( __ ( 'Blog Index Sidebar' , 'novusopress' ) , 'sidebar' , 'index' ) ; $ this -> registerWidget ( __ ( 'Blog Post Sidebar' , 'novusopress' ) , 'sidebar' , 'single' ) ; $ this -> registerWidget ( __ ( 'Front Page Sidebar' , 'novusopress' ) , 'sidebar' , 'front-page' ) ; $ this -> registerWidget ( __ ( 'Standard Page Sidebar' , 'novusopress' ) , 'sidebar' , 'page' ) ; $ this -> registerWidget ( __ ( 'Archive List Sidebar' , 'novusopress' ) , 'sidebar' , 'archive' ) ; $ this -> registerWidget ( __ ( 'Search Results Sidebar' , 'novusopress' ) , 'sidebar' , 'search' ) ; $ this -> registerWidget ( __ ( 'Attachment View Sidebar' , 'novusopress' ) , 'sidebar' , 'attachment' ) ; $ this -> registerWidget ( __ ( '404 Error Sidebar' , 'novusopress' ) , 'sidebar' , 'not-found' ) ; $ this -> registerWidget ( __ ( 'Footer Area One' , 'novusopress' ) , 'footer' , 'one' ) ; $ this -> registerWidget ( __ ( 'Footer Area Two' , 'novusopress' ) , 'footer' , 'two' ) ; $ this -> registerWidget ( __ ( 'Footer Area Three' , 'novusopress' ) , 'footer' , 'three' ) ; $ this -> registerWidget ( __ ( 'Footer Area Four' , 'novusopress' ) , 'footer' , 'four' ) ; }
Enables default widget support
19,749
public function cleanDocumentHead ( ) { remove_action ( 'wp_head' , 'feed_links_extra' ) ; remove_action ( 'wp_head' , 'feed_links' ) ; remove_action ( 'wp_head' , 'rsd_link' ) ; remove_action ( 'wp_head' , 'wlwmanifest_link' ) ; remove_action ( 'wp_head' , 'index_rel_link' ) ; remove_action ( 'wp_head' , 'parent_post_rel_link' , 10 ) ; remove_action ( 'wp_head' , 'start_post_rel_link' , 10 ) ; remove_action ( 'wp_head' , 'adjacent_posts_rel_link_wp_head' , 10 ) ; remove_action ( 'wp_head' , 'wp_generator' ) ; }
Removes extra markup from the document head
19,750
public function setViewLevel ( $ view_level_name , $ view_level_file_name ) { if ( isset ( $ this -> _view_levels [ $ view_level_name ] ) ) { $ this -> _view_levels [ $ view_level_name ] [ "file_name" ] = $ view_level_file_name ; $ this -> _view_levels [ $ view_level_name ] [ "is_disabled" ] = false ; } }
Attach a file name to a view level enables the view level
19,751
public function disableViewLevel ( $ view_level_name ) { if ( isset ( $ this -> _view_levels [ $ view_level_name ] ) ) { $ this -> _view_levels [ $ level_name ] [ "is_disabled" ] = true ; } }
Disables a view level
19,752
public function enableCache ( $ options = null ) { $ key = isset ( $ options [ "key" ] ) ? $ options [ "key" ] : "" ; $ lifetime = isset ( $ options [ "lifetime" ] ) ? $ options [ "lifetime" ] : 3600 ; $ level = isset ( $ options [ "level" ] ) ? $ options [ "level" ] : 1 ; $ this -> _cache_service_name = isset ( $ options [ "service" ] ) ? $ options [ "service" ] : "cache" ; $ view_level_name = $ this -> _getViewLevelNameFromLevel ( $ level ) ; $ this -> _view_levels [ $ view_level_name ] [ "cache_enabled" ] = array ( "key" => $ key , "lifetime" => $ lifetime ) ; }
Enables caching .
19,753
private function _checkViewsExist ( ) { foreach ( $ this -> _view_levels as $ view_level ) { if ( ! $ view_level [ "is_disabled" ] ) { if ( ! file_exists ( $ this -> _views_dir . $ view_level [ "file_name" ] . ".phtml" ) ) { throw new \ Exception ( "View '" . $ view_level [ "file_name" ] . ".phtml' does not exist." ) ; } } } }
Private function . Checks the enabled view levels and makes sure the attached view exists .
19,754
public function getContent ( ) { if ( $ this -> _render_completed ) { return $ this -> _content ; } foreach ( $ this -> _view_levels as $ view_level ) { if ( $ view_level [ "is_disabled" ] ) { continue ; } $ this -> _view_levels [ $ view_level [ "name" ] ] [ "is_disabled" ] = true ; if ( $ view_level [ "cache_enabled" ] != false ) { $ this -> getCacheContent ( $ view_level ) ; return ; } include ( $ this -> _views_dir . $ view_level [ "file_name" ] . ".phtml" ) ; return ; } }
Includes the files attached to the view levels . Disabled view levels do not get included . MAIN_VIEW - > BEFORE_CONTROLLER_VIEW - > CONTROLLER_VIEW - > AFTER_CONTROLLER_VIEW - > ACTION_VIEW If a view level has cache enabled stop rendering
19,755
function interpolate ( $ message , array $ context = [ ] ) { $ replace = array ( ) ; foreach ( $ context as $ key => $ val ) { if ( ( $ key == 'exception' || $ key == 'throwable' ) && $ val instanceof \ Throwable ) { $ val = $ val -> getTraceAsString ( ) ; } if ( is_object ( $ val ) ) { $ val = 'Objects can not be interpolated.' ; } $ replace [ '{' . $ key . '}' ] = $ val ; } return strtr ( $ message , $ replace ) ; }
Interpolates context values into the message placeholders
19,756
public function watchForRead ( $ socketObject ) : void { $ rawSocket = $ this -> getRawSocket ( $ socketObject ) ; \ array_push ( $ this -> watchedSockets , $ rawSocket ) ; $ this -> watchedSocketObjects [ $ this -> getRawSocketKey ( $ rawSocket ) ] = $ socketObject ; }
Currently only supports watching read events
19,757
public function addPrefix ( RouteEvent $ event ) { $ route = $ event -> getRoute ( ) ; $ route -> setPath ( $ this -> prefix . $ route -> getPath ( ) ) ; }
Add a prefix on each route
19,758
public function getIndexByName ( $ name ) { foreach ( $ this -> sections as $ i => $ sec ) { if ( $ sec instanceof Section ) { if ( $ sec -> getName ( ) == $ name ) { return $ i ; } } } return - 1 ; }
Get section index by section name - 1 for not exists .
19,759
public function getSectionByName ( $ name ) { foreach ( $ this -> sections as $ i => $ sec ) { if ( $ sec instanceof Section ) { if ( $ sec -> getName ( ) == $ name ) { return $ sec ; } } } return null ; }
Get section by section name null for not exists .
19,760
public static function set ( $ name , $ value , $ expiration = null , $ path = null , $ domain = null , $ secure = null , $ http_only = null ) { if ( \ Fuel :: $ is_cli ) { return false ; } $ value = \ Fuel :: value ( $ value ) ; is_null ( $ expiration ) and $ expiration = static :: $ config [ 'expiration' ] ; is_null ( $ path ) and $ path = static :: $ config [ 'path' ] ; is_null ( $ domain ) and $ domain = static :: $ config [ 'domain' ] ; is_null ( $ secure ) and $ secure = static :: $ config [ 'secure' ] ; is_null ( $ http_only ) and $ http_only = static :: $ config [ 'http_only' ] ; $ expiration = $ expiration > 0 ? $ expiration + time ( ) : 0 ; return setcookie ( $ name , $ value , $ expiration , $ path , $ domain , $ secure , $ http_only ) ; }
Sets a signed cookie . Note that all cookie values must be strings and no automatic serialization will be performed!
19,761
public static function delete ( $ name , $ path = null , $ domain = null , $ secure = null , $ http_only = null ) { unset ( $ _COOKIE [ $ name ] ) ; return static :: set ( $ name , null , - 86400 , $ path , $ domain , $ secure , $ http_only ) ; }
Deletes a cookie by making the value null and expiring it .
19,762
public function prepareException ( MvcEvent $ e ) { if ( $ e -> getRequest ( ) instanceof Request ) { $ error = $ e -> getError ( ) ; if ( ! empty ( $ error ) && ! $ e -> getResult ( ) instanceof Response ) { switch ( $ error ) { case Application :: ERROR_CONTROLLER_NOT_FOUND : case Application :: ERROR_CONTROLLER_INVALID : case Application :: ERROR_ROUTER_NO_MATCH : return ; case Application :: ERROR_EXCEPTION : default : $ exception = $ e -> getParam ( 'exception' ) ; foreach ( $ this -> whoopsConfig [ 'blacklist' ] as $ except ) { if ( $ exception instanceof $ except ) { return ; } } if ( $ this -> whoopsConfig [ 'handler' ] [ 'options_type' ] === 'prettyPage' ) { $ response = $ e -> getResponse ( ) ; if ( ! $ response || $ response -> getStatusCode ( ) === 200 ) { header ( 'HTTP/1.0 500 Internal Server Error' , true , 500 ) ; } ob_clean ( ) ; } $ this -> run -> handleException ( $ e -> getParam ( 'exception' ) ) ; break ; } } } }
Whoops handle exceptions
19,763
public function recordThat ( DomainEvent $ event ) { $ this -> bumpVersion ( ) ; if ( is_null ( $ this -> uncommittedEvents ) ) { $ this -> uncommittedEvents = new UncommittedEvents ( $ this -> getIdentity ( ) ) ; } $ this -> uncommittedEvents -> append ( $ event ) ; $ this -> when ( $ event ) ; return $ this ; }
Register a event happening on the aggregate
19,764
public function toArray ( ) { return [ 'id' => $ this -> id , 'author' => $ this -> author , 'title' => $ this -> title , 'date' => $ this -> date -> format ( 'U' ) , 'component' => $ this -> component , 'image' => $ this -> image , 'handler' => $ this -> handler , ] ; }
Return array repesentation of this search result .
19,765
protected function send ( $ msg ) { $ msg .= PHP_EOL ; return socket_write ( $ this -> socket , $ msg , strlen ( $ msg ) ) ; }
Atomic send of a string trough the socket
19,766
public function getCatalogIndex ( $ projectId = null ) { return $ this -> callService ( $ this -> url_plan [ 'get_catalog_index' ] , array ( 'project_id' => $ projectId ? : $ this -> project_id , ) ) ; }
Get catalog index
19,767
public function addCommandHandler ( CommandHandlerInterface $ commandHandler , string $ payloadName ) : CommandDispatcher { $ this -> commandHandlers [ $ payloadName ] = $ commandHandler ; return $ this ; }
Add command handler for payload name .
19,768
protected function getCommandHandler ( CommandMessageInterface $ commandMessage ) : CommandHandlerInterface { $ name = $ commandMessage -> getPayloadType ( ) -> getName ( ) ; $ commandHandlers = $ this -> getCommandHandlers ( ) ; if ( array_key_exists ( $ name , $ commandHandlers ) === false ) { throw new CommandHandlerNotFound ( $ commandMessage ) ; } return $ commandHandlers [ $ name ] ; }
Get command handler for command message .
19,769
protected function formatStub ( $ stub , array $ replacement ) { foreach ( $ replacement as $ src => $ dest ) { $ stub = str_replace ( $ src , $ dest , $ stub ) ; } return $ stub ; }
replace stub text
19,770
protected function store ( $ stub ) { $ output = $ this -> getOutputPath ( ) ; if ( $ this -> files -> exists ( $ output ) ) { return false ; } $ this -> files -> put ( $ output , $ stub ) ; return true ; }
save formatted stub text
19,771
public function getSlugForTitle ( $ title ) { $ slug = Str :: slug ( $ title ) ; $ latestSlug = $ this -> model -> whereRaw ( "slug RLIKE '^{$slug}(-[0-9]*)?$'" ) -> latest ( ) -> value ( 'slug' ) ; if ( $ latestSlug ) { $ pieces = explode ( '-' , $ latestSlug ) ; $ number = end ( $ pieces ) ; return $ slug . '-' . ( $ number + 1 ) ; } return $ slug ; }
Generate a unique Slug for a given Title .
19,772
public function findByRoot ( $ rootParagraphId ) { $ root = ( ( int ) $ rootParagraphId ) ? : null ; $ extra = $ this -> getMapper ( ) -> findByRoot ( $ root ) ; if ( empty ( $ extra ) ) { $ extra = $ this -> getMapper ( ) -> create ( array ( 'rootParagraphId' => $ root , ) ) ; } return $ extra ; }
Get customize extra by selector & media
19,773
protected function getMemoryLimit ( ) : ? int { $ short = [ 'k' => 1024 , 'm' => 1048576 , 'g' => 1073741824 , ] ; $ setting = ( string ) ini_get ( 'memory_limit' ) ; if ( ! ( $ len = strlen ( $ setting ) ) ) { return null ; } $ last = strtolower ( $ setting [ $ len - 1 ] ) ; $ numeric = ( int ) $ setting ; $ numeric *= isset ( $ short [ $ last ] ) ? $ short [ $ last ] : 1 ; return $ numeric ; }
Returns the memory limit in bytes .
19,774
protected function build ( $ in , $ out ) { $ workDir = getenv ( 'WORK_DIR' ) . '/' ; $ content = $ this -> filesystem -> read ( $ workDir . $ in ) ; $ document = $ this -> builder -> build ( $ content ) ; $ this -> filesystem -> overwrite ( $ workDir . $ out , $ document ) ; }
Build a Markdown document .
19,775
private function buildMenuWithoutExistingParent ( $ menuAccessible ) { $ withoutParent = collect ( $ this -> itemsWithoutParent ) -> unique ( 'route' ) -> all ( ) ; foreach ( $ withoutParent as & $ item ) { $ children = $ this -> buildMenuTree ( $ menuAccessible , $ item [ 'route' ] ) ; if ( $ children ) { $ item [ 'children' ] = $ children ; } } return $ withoutParent ; }
Add child menu items to their parents . Only two levels
19,776
protected function init ( ) { $ this -> dependencies = array ( ) ; foreach ( $ this -> context -> getDependenciesFile ( ) as $ nameFile ) { $ this -> dependencies = array_merge ( $ this -> dependencies , $ this -> context -> readConfigurationFile ( $ nameFile ) ) ; } $ this -> loadDependencies = array ( ) ; foreach ( $ this -> dependencies as $ key => $ value ) { if ( isset ( $ value [ 'load_in' ] ) ) { $ this -> loadDependencies [ $ key ] = $ value ; } } }
Realiza lar carga inicial
19,777
public function injectDependenciesOfType ( $ object , $ type ) { foreach ( $ this -> loadDependencies as $ name => $ dependency ) { $ types = explode ( "," , $ dependency [ 'load_in' ] ) ; if ( in_array ( $ type , $ types ) ) { $ this -> loadDependencyInObject ( $ object , $ name , $ name , $ dependency ) ; } } }
Recorre las dependencias con load_in y analiza si carga o no una instancia de la dependencia en el objeto . Las nombres de las propiedades son las claves en la definicion de cada dependencia Es llamado por GenericLoader en su construccion para inyectar las clases correspondientes . Esta funcion supone que las Clases de la dependencia ya se encuentran importadas .
19,778
public function injectDependencies ( $ object , array $ dependencies ) { $ dependenciesDefinition = $ this -> dependencies ; foreach ( $ dependencies as $ property => $ dependencyName ) { if ( isset ( $ dependenciesDefinition [ $ dependencyName ] ) ) { $ dependency = $ dependenciesDefinition [ $ dependencyName ] ; $ this -> loadDependencyInObject ( $ object , $ property , $ dependencyName , $ dependency ) ; } } }
Carga cada una de las dependencias indicadas en su correspondiente propiedad del objeto Esta funcion supone que las Clases de las dependencias ya se encuentran importadas .
19,779
public function getDependencyInstance ( $ dependencyName ) { if ( isset ( $ this -> dependencies [ $ dependencyName ] ) ) { return $ this -> loadDependency ( $ dependencyName , $ this -> dependencies [ $ dependencyName ] ) ; } return null ; }
Retorna una dependencia instanciada En este caso la dependencia no se injecta a ningun objeto
19,780
public function injectProperties ( $ object , $ propertiesDefinition ) { $ properties = $ this -> parseProperties ( $ propertiesDefinition ) ; $ reflection = new Reflection ( $ object ) ; $ reflection -> setProperties ( $ properties , TRUE ) ; }
Injecta definicion de propiedades a una instancia
19,781
protected function loadDependencyInObject ( $ object , $ property , $ dependencyName , $ dependencyDefinition ) { $ dependency = $ this -> loadDependency ( $ dependencyName , $ dependencyDefinition ) ; $ reflection = new Reflection ( $ object ) ; $ reflection -> setProperty ( $ property , $ dependency , TRUE ) ; }
Carga la dependencia y la setea en la propiedad del objeto a inyectar
19,782
protected function loadDependency ( $ name , $ dependencyDefinition , & $ loadedDependencies = array ( ) ) { $ newInstance = NULL ; if ( isset ( $ this -> singletons [ $ name ] ) ) { $ newInstance = $ this -> singletons [ $ name ] ; } else { $ namespace = ( isset ( $ dependencyDefinition [ 'namespace' ] ) ? $ dependencyDefinition [ 'namespace' ] : '' ) ; $ dir = explode ( "/" , $ dependencyDefinition [ 'class' ] ) ; $ class = $ dir [ count ( $ dir ) - 1 ] ; if ( $ namespace != '' ) { $ class = "\\" . $ namespace . "\\" . $ class ; } $ newInstance = NULL ; if ( isset ( $ dependencyDefinition [ 'factory-method' ] ) ) { $ factoryMethod = $ dependencyDefinition [ 'factory-method' ] ; if ( isset ( $ dependencyDefinition [ 'factory-bean' ] ) ) { $ factoryBean = $ this -> getDependency ( $ dependencyDefinition [ 'factory-bean' ] , $ loadedDependencies ) ; $ newInstance = $ factoryBean -> $ factoryMethod ( ) ; } else { $ newInstance = $ class :: $ factoryMethod ( ) ; } } else { $ params = array ( ) ; if ( isset ( $ dependencyDefinition [ 'construct' ] ) ) { $ params = $ this -> parseProperties ( $ dependencyDefinition [ 'construct' ] ) ; } $ reflection = new \ ReflectionClass ( $ class ) ; $ newInstance = $ reflection -> newInstanceArgs ( $ params ) ; $ loadedDependencies [ $ name ] = $ newInstance ; } if ( isset ( $ dependencyDefinition [ 'singleton' ] ) && ( $ dependencyDefinition [ 'singleton' ] == "TRUE" || $ dependencyDefinition [ 'singleton' ] == "true" ) ) { $ this -> singletons [ $ name ] = $ newInstance ; } if ( isset ( $ dependencyDefinition [ 'properties' ] ) ) { $ properties = $ this -> parseProperties ( $ dependencyDefinition [ 'properties' ] , $ loadedDependencies ) ; $ reflection = new Reflection ( $ newInstance ) ; $ reflection -> setProperties ( $ properties , TRUE ) ; } } return $ newInstance ; }
Realiza la carga de una dependencia que luego va a ser inyectada
19,783
protected function parseProperties ( $ propertiesDefinition , & $ loadedDependencies = array ( ) ) { $ parseProperties = array ( ) ; foreach ( $ propertiesDefinition as $ key => $ definition ) { $ property = NULL ; if ( isset ( $ definition [ 'ref' ] ) ) { $ property = $ this -> getDependency ( $ definition [ 'ref' ] , $ loadedDependencies ) ; } else { $ property = $ definition [ 'value' ] ; if ( $ definition [ 'value' ] != 'array' ) { settype ( $ property , $ definition [ 'type' ] ) ; } } $ parseProperties [ $ key ] = $ property ; } return $ parseProperties ; }
Parsea los valores en string al tipo que corresponda segun el valor y el tipo definido .
19,784
protected function getDependency ( $ name , & $ loadedDependencies = array ( ) ) { $ dependency = NULL ; $ dependencies = $ this -> dependencies ; if ( isset ( $ dependencies [ $ name ] ) ) { if ( isset ( $ loadedDependencies [ $ name ] ) ) { $ dependency = $ loadedDependencies [ $ name ] ; } else { $ dependency = $ this -> loadDependency ( $ name , $ dependencies [ $ name ] , $ loadedDependencies ) ; } } return $ dependency ; }
Devuelve la dependencia en base a un nombre y una lista de dependencias . Si no existe devuelve NULL
19,785
public function render ( $ viewPath , array $ params = [ ] ) { ob_start ( ) ; ob_implicit_flush ( false ) ; $ this -> params = $ params ; extract ( array_merge ( $ params , $ this -> getBlocks ( ) ) , EXTR_OVERWRITE ) ; require ( file_exists ( $ viewPath ) ? $ viewPath : '../' . $ viewPath ) ; return ob_get_clean ( ) ; }
Render view file
19,786
public function content ( $ parentView = null ) { if ( $ parentView === null ) { $ content = ob_get_clean ( ) ; ob_clean ( ) ; $ this -> params [ 'scripts' ] = $ this -> generateScripts ( ) ; $ this -> params [ 'css' ] = $ this -> generateCSS ( ) ; echo $ this -> render ( $ this -> parentLayout , array_merge ( $ this -> getBlocks ( ) , $ this -> params , [ 'content' => $ content ] ) ) ; } else { $ this -> parentLayout = $ parentView ; ob_start ( ) ; } }
Content for parent layout
19,787
public function block ( $ name = null ) { if ( $ name === null ) { $ this -> addBlock ( $ this -> currentBlock , ob_get_clean ( ) ) ; $ this -> currentBlock = '' ; ob_clean ( ) ; } else { $ this -> currentBlock = $ name ; ob_start ( ) ; } }
Start or stop content block
19,788
public function generateScripts ( ) { $ result = '' ; $ rawScript = [ ] ; $ this -> scripts = array_unique ( $ this -> scripts , SORT_REGULAR ) ; foreach ( $ this -> scripts as $ scriptInfo ) { if ( ! $ scriptInfo [ 2 ] ) { $ result .= '<script src="' . $ scriptInfo [ 0 ] . '" type="' . $ scriptInfo [ 1 ] . '"></script>' ; } else { $ rawScript [ $ scriptInfo [ 1 ] ] = isset ( $ rawScript [ $ scriptInfo [ 1 ] ] ) ? $ rawScript [ $ scriptInfo [ 1 ] ] .= $ scriptInfo [ 0 ] : $ scriptInfo [ 0 ] ; } } foreach ( $ rawScript as $ type => $ script ) { $ result .= '<script type="' . $ type . '">' . $ script . '</script>' ; } return $ result ; }
Generate script tags
19,789
public function generateCSS ( ) { $ result = '' ; $ cssRaw = '' ; $ this -> styles = array_unique ( $ this -> styles , SORT_REGULAR ) ; foreach ( $ this -> styles as $ style ) { if ( $ style [ 1 ] ) { $ cssRaw .= $ style [ 0 ] ; } else { $ result .= '<link href="' . $ style [ 0 ] . '" rel="stylesheet" type="text/css" />' ; } } $ result .= $ cssRaw != '' ? '<style>' . $ cssRaw . '</style>' : '' ; return $ result ; }
Generate CSS tags
19,790
public function load ( $ file , $ type = null ) { $ path = $ this -> locator -> locate ( $ file ) ; $ collection = new RouteCollection ( ) ; if ( $ class = $ this -> findClass ( $ path ) ) { $ collection -> addResource ( new FileResource ( $ path ) ) ; $ module = $ this -> moduleManager -> get ( $ class ) ; $ routeNamePrefix = $ module -> getRouteNamePrefix ( ) ; $ routePatternPrefix = $ module -> getRoutePatternPrefix ( ) ; foreach ( $ module -> getRouteActions ( ) as $ action ) { $ reflection = new \ ReflectionObject ( $ action ) ; $ collection -> addResource ( new FileResource ( $ reflection -> getFileName ( ) ) ) ; $ name = $ routeNamePrefix . $ action -> getRouteName ( ) ; if ( '/' === $ action -> getRoutePattern ( ) && '' !== $ routePatternPrefix ) { $ pattern = $ routePatternPrefix ; } else { $ pattern = $ routePatternPrefix . $ action -> getRoutePattern ( ) ; } $ defaults = array_merge ( $ action -> getRouteDefaults ( ) , array ( '_controller' => 'PablodipModuleBundle:Module:execute' , '_module.module' => $ class , '_module.action' => $ action -> getName ( ) , ) ) ; $ requirements = $ action -> getRouteRequirements ( ) ; $ options = $ action -> getRouteOptions ( ) ; $ collection -> add ( $ name , new Route ( $ pattern , $ defaults , $ requirements , $ options ) ) ; } } return $ collection ; }
Loads from modules in a file
19,791
public function appendHeadScript ( $ src , $ isFile = true ) { $ this -> headScripts [ ] = $ this -> createScript ( $ src , $ isFile ) ; }
Append script to header
19,792
public function prependHeadScript ( $ src , $ isFile = true ) { $ script = $ this -> createScript ( $ src , $ isFile ) ; $ scripts = $ this -> headScripts ; array_unshift ( $ scripts , $ script ) ; $ this -> headScripts = $ scripts ; }
Prepend script to header
19,793
public function getHeadScripts ( ) { $ output = '' ; foreach ( $ this -> headScripts as $ script ) { $ output .= $ script . "\n" ; } $ output = rtrim ( $ output , "\n" ) ; return $ output ; }
Get header script
19,794
public function appendAfterBodyScript ( $ src , $ isFile = true ) { $ this -> afterBodyScripts [ ] = $ this -> createScript ( $ src , $ isFile ) ; }
Append after body script
19,795
public function prependAfterBodyScript ( $ src , $ isFile = true ) { $ script = $ this -> createScript ( $ src , $ isFile ) ; $ scripts = $ this -> afterBodyScripts ; array_unshift ( $ scripts , $ script ) ; $ this -> afterBodyScripts = $ scripts ; }
Prepend after body script
19,796
public function getAfterBodyScripts ( ) { $ output = '' ; foreach ( $ this -> afterBodyScripts as $ script ) { $ output .= $ script . "\n" ; } $ output = rtrim ( $ output , "\n" ) ; return $ output ; }
Get after body script
19,797
protected function findModule ( ) { if ( $ this -> isGreenPage ( ) ) { $ moduleName = $ this -> DesignModule ; if ( $ moduleName ) { return Green :: inst ( ) -> getDesignModule ( $ moduleName ) ; } } $ url = $ this -> request -> getURL ( ) ; foreach ( Green :: inst ( ) -> getDesignModules ( ) as $ module ) { if ( ( string ) $ module -> getConfiguration ( ) -> public_url == $ url ) { return $ module ; } } return false ; }
Finds the DesignModule object whether through the attached data record or through the public_url match
19,798
protected function handleAction ( $ request , $ action ) { $ module = $ this -> findModule ( ) ; if ( ! $ module ) { return parent :: handleAction ( $ request , $ action ) ; } $ data = [ ] ; if ( $ this -> isGreenPage ( ) ) { $ data = $ this -> data ( ) -> toViewableData ( ) ; } elseif ( $ module -> getDataSource ( ) ) { $ data = $ module -> getDataSource ( ) -> toDBObject ( ) ; } $ module -> loadRequirements ( ) ; $ viewer = $ this -> getViewer ( $ action ) ; $ viewer -> setTemplateFile ( 'Layout' , $ module -> getLayoutTemplateFile ( ) ) ; $ main = $ module -> getMainTemplateFile ( ) ; if ( $ main ) { $ viewer -> setTemplateFile ( 'main' , $ main ) ; } return $ viewer -> process ( $ this -> customise ( $ data ) ) ; }
Intercepts the handleAction method to force a customised viewer
19,799
public function insert ( array $ values ) { $ batch = true ; foreach ( $ values as $ value ) { if ( ! is_array ( $ value ) ) { $ batch = false ; break ; } } if ( ! $ batch ) { $ values = [ $ values ] ; } $ result = $ this -> collection -> insertMany ( $ values ) ; return ( 1 == ( int ) $ result -> isAcknowledged ( ) ) ; }
Insert documents .