idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
55,600
protected function generateModel ( $ modelClassName , $ modelTpl ) { file_put_contents ( Lb :: app ( ) -> getRootDir ( ) . DIRECTORY_SEPARATOR . '/models/' . $ modelClassName . '.php' , $ modelTpl ) ; }
Generate model file
55,601
protected function encode ( $ from , $ text , $ html , $ whole = true ) { $ html = str_replace ( $ from . ' ' , $ text . ' ' , $ html ) ; $ html = str_replace ( ' ' . $ from , ' ' . $ text , $ html ) ; $ html = str_replace ( '>' . $ from , '>' . $ text , $ html ) ; $ html = str_replace ( $ from . '<' , $ text . '<' , $...
Converts the specified string .
55,602
public function install ( ) { $ this -> setOptions ( $ this -> config -> options ( ) ) ; $ this -> activatePlugins ( $ this -> config -> plugins ( ) ) ; if ( $ theme = $ this -> config -> theme ( ) ) { $ this -> setTheme ( $ theme -> name , $ theme -> mods , $ theme -> options , $ theme -> menus , $ theme -> sidebars )...
Run the install scripts .
55,603
public function setTheme ( $ theme , array $ mods = [ ] , array $ options = [ ] , array $ menus = [ ] , array $ sidebars = [ ] ) { $ this -> setOptions ( $ options ) ; switch_theme ( $ theme ) ; $ this -> setThemeMods ( $ mods ) ; $ this -> createMenus ( $ menus ) ; $ this -> setupSidebars ( $ sidebars ) ; }
Set a theme and possible mods related options and menus .
55,604
public function setPermalinkStructure ( $ wp_rewrite , $ structure ) { $ wp_rewrite -> set_permalink_structure ( $ structure ) ; $ wp_rewrite -> flush_rules ( true ) ; update_option ( "rewrite_rules" , false ) ; }
Set and flush the permalink structure .
55,605
protected function createMenus ( $ menus ) { $ locations = [ ] ; foreach ( $ menus as $ menu ) { $ menu_id = $ this -> createMenu ( $ menu [ 'name' ] ) ; if ( $ menu_id ) { $ locations [ $ menu [ 'location' ] ] = $ menu_id ; $ this -> populateMenu ( $ menu_id , $ menu [ 'items' ] ) ; } } set_theme_mod ( 'nav_menu_locat...
Create fill and place WordPress menus .
55,606
protected function setupSidebars ( $ sidebars ) { $ active_widgets = get_option ( 'sidebars_widgets' ) ; foreach ( $ sidebars as $ sidebar => $ widgets ) { $ new_widgets = [ ] ; foreach ( $ widgets as $ type => $ data ) { $ widget = get_option ( 'widget_' . $ type ) ; $ widget [ ] = $ data ; end ( $ widget ) ; $ id = k...
Add widgets to the theme sidebars .
55,607
protected function createMenu ( $ menu_name ) { $ menu_id = wp_create_nav_menu ( $ menu_name ) ; if ( ! is_object ( $ menu_id ) && intval ( $ menu_id ) > 0 ) { return $ menu_id ; } return false ; }
Create a new WordPress menu .
55,608
protected function populateMenu ( $ menu_id , $ menu_items ) { foreach ( $ menu_items as $ menu_item ) { if ( isset ( $ menu_item [ 'title' ] ) && isset ( $ menu_item [ 'type' ] ) ) { wp_update_nav_menu_item ( $ menu_id , 0 , $ this -> getMenuItemData ( $ menu_item [ 'type' ] , $ menu_item ) ) ; } } }
Add menu items to menu .
55,609
private function getMenuItemData ( $ type , $ data ) { if ( 'page' == $ type ) { return $ this -> getPageMenuItem ( $ data ) ; } if ( 'post' == $ type ) { return $ this -> getPostMenuItem ( $ data ) ; } return $ this -> getCustomMenuItem ( $ data ) ; }
Converts data for a menu item .
55,610
public function getSorts ( ) { $ ret = [ ] ; foreach ( $ this -> fields as $ alias => $ description ) { $ ret [ $ alias ] = $ description [ 'label' ] ; } return $ ret ; }
Implementors should override this method to add their sorts
55,611
protected function applyFilters ( \ SelectQueryInterface $ select , Query $ query ) { foreach ( $ this -> fields as $ name => $ description ) { if ( $ query -> has ( $ name ) ) { $ select -> condition ( $ description [ 'column' ] , $ query -> get ( $ name ) ) ; } } }
Process field filters
55,612
final protected function process ( \ SelectQueryInterface $ select , Query $ query ) { $ sortField = null ; if ( $ query -> hasSortField ( ) ) { $ sortField = $ query -> getSortField ( ) ; $ select -> orderBy ( $ this -> fields [ $ sortField ] [ 'column' ] , Query :: SORT_DESC === $ query -> getSortOrder ( ) ? 'desc' :...
Process paging and full text search
55,613
public function getUnsigned ( ) { $ payload = [ ] ; foreach ( $ this -> data as $ key => $ value ) { if ( in_array ( $ key , $ this -> accessors ) ) { $ payload [ $ key ] = $ value ; } elseif ( in_array ( $ key , $ this -> customFields ) ) { $ payload [ 'custom.' . $ key ] = $ value ; } } return QueryString :: normaliz...
Returns the payload as an unsigned queryString .
55,614
private function resolveCustom ( $ key ) { if ( is_array ( $ key ) ) { foreach ( $ key as $ k => $ v ) { $ this -> resolveCustom ( $ k ) ; } } else { if ( ! in_array ( $ key , $ this -> reserved ) ) { $ this -> customFields [ ] = $ key ; } } }
Adds the key to the customFields array unless the key is a reserved one .
55,615
protected function getSiteURL ( $ value ) { if ( ! IS :: url ( $ value ) ) { $ value = Request :: getSiteURL ( $ value ) ; } return $ value ; }
Protected get site url
55,616
public function registerAssetFiles ( $ view ) { parent :: registerAssetFiles ( $ view ) ; $ localeEncoded = Json :: encode ( Yii :: $ app -> language ) ; $ js = <<<jsvar polyglot = new Polyglot({locale: $localeEncoded});js ; Yii :: $ app -> controller -> getView ( ) -> registerJs ( $ js , \ yii \ web \ View :: POS_HEA...
This function extends default AssetBundle behavior adding Polyglot initialization call right after including asset files
55,617
public function initSmartyFilterI18ns ( $ overrideExisting = true ) { if ( null !== $ this -> collSmartyFilterI18ns && ! $ overrideExisting ) { return ; } $ this -> collSmartyFilterI18ns = new ObjectCollection ( ) ; $ this -> collSmartyFilterI18ns -> setModel ( '\SmartyFilter\Model\SmartyFilterI18n' ) ; }
Initializes the collSmartyFilterI18ns collection .
55,618
public function getSmartyFilterI18ns ( $ criteria = null , ConnectionInterface $ con = null ) { $ partial = $ this -> collSmartyFilterI18nsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collSmartyFilterI18ns || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && null === $ this -> collSmartyFil...
Gets an array of ChildSmartyFilterI18n objects which contain a foreign key that references this object .
55,619
public function countSmartyFilterI18ns ( Criteria $ criteria = null , $ distinct = false , ConnectionInterface $ con = null ) { $ partial = $ this -> collSmartyFilterI18nsPartial && ! $ this -> isNew ( ) ; if ( null === $ this -> collSmartyFilterI18ns || null !== $ criteria || $ partial ) { if ( $ this -> isNew ( ) && ...
Returns the number of related SmartyFilterI18n objects .
55,620
public function addSmartyFilterI18n ( ChildSmartyFilterI18n $ l ) { if ( $ l && $ locale = $ l -> getLocale ( ) ) { $ this -> setLocale ( $ locale ) ; $ this -> currentTranslations [ $ locale ] = $ l ; } if ( $ this -> collSmartyFilterI18ns === null ) { $ this -> initSmartyFilterI18ns ( ) ; $ this -> collSmartyFilterI1...
Method called to associate a ChildSmartyFilterI18n object to this object through the ChildSmartyFilterI18n foreign key attribute .
55,621
protected function cast ( $ input , SplObjectStorage $ list ) { $ value = $ input instanceof JsonSerializable ? $ input -> jsonSerialize ( ) : $ input ; if ( $ value instanceof DateTimeInterface ) { $ value = $ value -> format ( DateTime :: ISO8601 ) ; } if ( is_iterable ( $ value ) ) { $ value = i \ iterable_to_array ...
Cast value for json serialization .
55,622
protected function castRecursive ( $ source , $ values , SplObjectStorage $ list ) { if ( is_object ( $ source ) ) { $ list [ $ source ] = null ; } foreach ( $ values as $ key => & $ value ) { if ( ! is_object ( $ value ) || ! $ list -> contains ( $ value ) ) { $ value = $ this -> cast ( $ value , $ list ) ; } elseif (...
Cast value recursively .
55,623
public function transform ( SplFileInfo $ file ) { $ data = $ this -> parser -> parse ( $ file -> getContents ( ) ) ; $ missingFields = $ this -> getMissingFields ( $ data ) ; if ( false === empty ( $ missingFields ) ) { throw new TransformationFailure ( sprintf ( 'Missing required fields (%s) in taxonomy file: %s' , i...
Transform a taxonomy YAML into a TaxonomyFile object
55,624
public static function decode ( $ data ) { if ( ! is_string ( $ data ) ) { throw new InvalidArgumentException ( 'data must be string' ) ; } if ( 1 === strlen ( $ data ) % 4 ) { throw new InvalidArgumentException ( 'invalid base64 string length' ) ; } $ result = base64_decode ( $ data , true ) ; if ( false === $ result ...
Decode base64 .
55,625
function invite ( $ email , array $ parameters = [ ] , array $ emailParameters = [ ] ) { $ email = trim ( strtolower ( $ email ) ) ; if ( ! filter_var ( $ email , FILTER_VALIDATE_EMAIL ) ) { throw new AuthException ( 'Please enter a valid email address.' ) ; } $ userClass = $ this -> auth -> getUserClass ( ) ; $ user =...
Invites a user by email address . If the user does not exist then a temporary one will be created . If there is an existing user then it will be returned .
55,626
private function getConnection ( ) { if ( $ this -> newConnection ) { $ this -> mysqlRef = new MysqlConnection ( $ this -> host , $ this -> user , $ this -> password , $ this -> name , $ this -> key , $ this -> cert , $ this -> ca ) ; $ this -> mysqlRef -> connect ( ) ; } else { $ this -> mysqlRef = $ this -> mysqlConn...
Get the connection according to newConnection value
55,627
public function executeQuery ( $ query ) { $ results = $ this -> mysqliRef -> query ( $ query ) ; if ( ! $ results ) { $ mex = "Mysql error " . $ this -> mysqliRef -> error . " on '" . $ query . "''" ; $ this -> log ( $ mex ) ; throw new MysqltcsException ( $ mex ) ; } else { $ this -> log ( $ query ) ; return $ result...
Execute an sql query and log it
55,628
public function AvailableSectionTypes ( ) { $ AvailableTypes = ClassInfo :: subclassesfor ( 'Section' ) ; unset ( $ AvailableTypes [ 'Section' ] ) ; $ pageTypeOptions = Config :: inst ( ) -> get ( $ this -> owner -> ClassName , 'section_options' ) ; foreach ( $ AvailableTypes as $ key => $ value ) { $ Config = Config :...
Lists all sections types and their settings relative to the current page type .
55,629
protected function taskPartialCleanDirs ( $ dirs , Finder $ finder = null , Filesystem $ fs = null ) { return $ this -> task ( PartialCleanDirs :: class , $ dirs , $ finder , $ fs ) ; }
Creates a new PartialCleanDir task .
55,630
function exchangeToken ( ) { $ this -> isTokenExchanged = true ; $ token = $ this -> client -> attainAccessToken ( $ this -> grant ) ; return $ this -> token = $ token ; }
Exchange New Token
55,631
public function add ( $ field_list ) { if ( ! is_array ( $ field_list ) ) return false ; foreach ( $ field_list as $ value ) { $ field = new Query_Field ( ) ; if ( count ( $ value ) == 1 ) { $ field -> name = $ value ; $ this -> field_list [ $ value ] = $ field ; continue ; } $ field -> name = $ value [ 'name' ] ; $ fi...
adds fields based on an array
55,632
public function getPublicUrl ( $ path , $ absolute = false ) { return sprintf ( '%s/%s' , $ absolute ? $ this -> root : null , ltrim ( $ path , '/' ) ) ; }
Get public url for the given path
55,633
public function setDocumentFile ( File $ documentFile = null ) { $ this -> documentFile = $ documentFile ; if ( $ documentFile ) { $ this -> modified = new \ DateTimeImmutable ( ) ; } return $ this ; }
documentFile property is not persisted!
55,634
function mod ( $ data , $ op = null ) { if ( is_string ( $ data ) ) { $ data = $ this -> row -> getTable ( ) -> getConnection ( ) -> quote ( $ data ) ; } parent :: mod ( $ data , $ op ) ; $ this -> dirty = true ; return $ this ; }
Modify the value in this cell
55,635
public function getArray ( $ arrType = 'assoc' ) { $ arr = [ ] ; $ arr [ 'leadingInit' ] = $ this -> leadingInit ; $ arr [ 'first' ] = $ this -> first ; $ arr [ 'nicknames' ] = $ this -> nicknames ; $ arr [ 'middle' ] = $ this -> middle ; $ arr [ 'last' ] = $ this -> last ; $ arr [ 'suffix' ] = $ this -> suffix ; if ( ...
returns all the parts of the name as an array .
55,636
final public static function instance ( ) { $ className = get_called_class ( ) ; if ( ! Arrays :: exists ( static :: $ instances [ $ className ] ) ) { static :: $ instances [ $ className ] = new $ className ( func_get_args ( ) ) ; } return static :: $ instances [ $ className ] ; }
Static method for instantiating a singleton object .
55,637
public function findFile ( $ class ) { $ file = apc_fetch ( $ this -> key . $ class ) ; if ( ! $ file ) { $ file = $ this -> loader -> findFile ( $ class ) ; apc_store ( $ this -> key . $ class , $ file ) ; } return $ file ; }
Finds the file from the cache or the autoloader
55,638
public function addNode ( Node $ node ) : self { $ id = $ node -> getId ( ) ; if ( isset ( $ this -> nodes [ $ id ] ) ) { throw new DuplicateNodeException ( sprintf ( "Node \"%s\" already present in the graph." , $ id ) ) ; } $ this -> nodes [ $ id ] = $ node ; $ this -> nodeAttrIndex -> insertElement ( $ node ) ; retu...
Add existing node to the graph .
55,639
public function getNode ( string $ id ) : Node { if ( isset ( $ this -> nodes [ $ id ] ) ) { return $ this -> nodes [ $ id ] ; } else { throw new MissingNodeException ( sprintf ( "Node \"%s\" not found in the graph." , $ id ) ) ; } }
Get node by its ID .
55,640
public function removeNode ( Node $ node ) : self { $ id = $ node -> getId ( ) ; if ( isset ( $ this -> nodes [ $ id ] ) ) { foreach ( $ node -> getConnectedEdges ( ) as $ e ) { $ e -> remove ( ) ; } unset ( $ this -> nodes [ $ id ] ) ; $ this -> nodeAttrIndex -> removeElement ( $ node ) ; return $ this ; } else { thro...
Remove node and connected edges from the graph .
55,641
public function createEdge ( string $ id = null , Node $ start , Node $ end , array $ attrs ) : Edge { if ( $ id === null ) { $ id = '_' . count ( $ this -> getRootGraph ( ) -> getAllEdges ( ) ) ; } return new Edge ( $ this , $ id , $ start , $ end , $ attrs ) ; }
Create a new edge and add it to the graph .
55,642
public function addEdge ( Edge $ edge ) : self { $ id = $ edge -> getId ( ) ; if ( isset ( $ this -> rootGraph -> edges [ $ id ] ) ) { throw new DuplicateEdgeException ( sprintf ( "Edge \"%s\" already present in the graph." , $ id ) ) ; } $ this -> edges [ $ id ] = $ edge ; $ this -> edgeAttrIndex -> insertElement ( $ ...
Add existing edge to the graph .
55,643
public function getEdge ( string $ id ) : Edge { if ( isset ( $ this -> edges [ $ id ] ) ) { return $ this -> edges [ $ id ] ; } else { throw new MissingEdgeException ( sprintf ( "Edge \"%s\" not found in the graph." , $ id ) ) ; } }
Get Edge by its ID .
55,644
public function removeEdge ( Edge $ edge ) : self { $ id = $ edge -> getId ( ) ; if ( isset ( $ this -> edges [ $ id ] ) ) { $ this -> edges [ $ id ] -> disconnectNodes ( ) ; unset ( $ this -> edges [ $ id ] ) ; $ this -> edgeAttrIndex -> removeElement ( $ edge ) ; return $ this ; } else { throw new MissingEdgeExceptio...
Remove edge from the graph and disconnect it from nodes .
55,645
private static function populateIds ( & $ insertModels , $ pks , $ lastPk , $ insertedCount ) { while ( $ insertedCount > 0 && $ insertedCount <= count ( $ insertModels ) ) { $ insertedCount -- ; $ model = $ insertModels [ $ insertedCount ] ; $ model -> { $ pks [ 0 ] } = $ lastPk ; $ lastPk = intval ( $ lastPk ) - 1 ; ...
Populate auto - increment IDs back to models after batch - inserting
55,646
public static function insertMultiple ( $ table , $ data ) { $ columns = [ ] ; $ i = 0 ; foreach ( $ data as $ dataRow ) { foreach ( $ dataRow as $ key => $ value ) { if ( ! array_key_exists ( $ key , $ columns ) ) { $ columns [ $ key ] = $ i ; $ i ++ ; } } } $ rows = [ ] ; foreach ( $ data as $ dataRow ) { $ row = [ ]...
Batch - insert a list of data to a table . This method could be used to achieve better performance during insertion of the large amount of data into the database table .
55,647
public static function updateMultiple ( $ table , $ data , $ pkNames , $ pkValues = null ) { $ command = self :: createMultipleUpdateCommand ( $ table , $ data , $ pkNames , $ pkValues ) ; return $ command -> execute ( ) ; }
Batch - update a list of data to a table . This method could be used to achieve better performance during insertion of the large amount of data into the database table .
55,648
public static function createMultipleDeleteCommand ( $ table , $ data , $ templates = null ) { if ( is_null ( $ templates ) ) { $ templates = [ 'rowDeleteStatement' => 'DELETE FROM {{tableName}} WHERE {{rowDeleteCondition}}' , 'columnValueGlue' => ',' , 'rowDeleteConditionExpression' => '{{colName}}={{colValue}}' , 'ro...
Creates a multiple DELETE command . This method compose the SQL expression via given part templates providing ability to adjust command for different SQL syntax .
55,649
public function prepareDataSource ( array $ dataSource ) { if ( isset ( $ dataSource [ 'data' ] [ 'items' ] ) ) { foreach ( $ dataSource [ 'data' ] [ 'items' ] as & $ item ) { $ name = $ this -> getData ( 'name' ) ; if ( isset ( $ item [ 'entity_id' ] ) ) { $ item [ $ name ] [ 'edit' ] = [ 'href' => $ this -> _urlBuild...
Prepare Data Source .
55,650
protected function obtainMySQLDatabaseInfoFromEnv ( $ file ) { $ env = ( new Loader ( $ file ) ) -> parse ( ) -> toArray ( ) ; if ( ! array_key_exists ( 'DB_CONNECTION' , $ env ) || $ env [ 'DB_CONNECTION' ] != 'mysql' ) { return null ; } if ( ! array_key_exists ( 'DB_DATABASE' , $ env ) || ! array_key_exists ( 'DB_USE...
Obtain MySQL Database Info From env file .
55,651
public function load ( IPost $ post ) { $ this -> template -> set ( 'title' , $ post -> getTitle ( ) ) ; $ this -> template -> set ( 'meta_title' , $ post -> metaTitle ( ) ) ; $ this -> template -> set ( 'meta_keywords' , $ post -> metaKeywords ( ) ) ; $ this -> template -> set ( 'meta_description' , $ post -> metaDesc...
Load post data to the template .
55,652
public function meet ( $ blueprint ) { $ parts = explode ( '.' , $ this -> dependency ) ; return $ this -> get ( $ parts , $ blueprint ) ; }
Solve the dependency path for a given blueprint or object
55,653
protected function get ( $ parts , $ subject ) { $ part = array_shift ( $ parts ) ; if ( ! $ this -> has ( $ part , $ subject ) ) { $ type = is_object ( $ subject ) ? get_class ( $ subject ) : gettype ( $ subject ) ; throw new \ Exception ( sprintf ( "Can't find %s in %s" , $ part , $ type ) ) ; } elseif ( is_array ( $...
Recursively search for the necessary parts of the dependency path
55,654
protected function has ( $ part , $ subject ) { return ( method_exists ( $ subject , $ part ) || ( is_array ( $ subject ) && array_key_exists ( $ part , $ subject ) ) || ( is_object ( $ subject ) && property_exists ( $ subject , $ part ) ) ) ; }
Check if the necessary part exists in the dependency
55,655
public function fields ( $ model , $ attributes , $ options = [ ] ) { $ config = $ this -> fieldConfig ; if ( $ config instanceof \ Closure ) { $ config = call_user_func ( $ config , $ model , $ attributes ) ; } if ( ! isset ( $ config [ 'class' ] ) ) { $ config [ 'class' ] = $ this -> fieldClass ; } return Yii :: crea...
Generates a form field by multiple model attributes .
55,656
public function isHasMany ( $ key ) { if ( false === $ this -> isRelationship ( $ key ) ) { return false ; } return $ this -> getMetadata ( ) -> getRelationship ( $ key ) -> isMany ( ) ; }
Determines if a property key is a has - many relationship .
55,657
public function isHasOne ( $ key ) { if ( false === $ this -> isRelationship ( $ key ) ) { return false ; } return $ this -> getMetadata ( ) -> getRelationship ( $ key ) -> isOne ( ) ; }
Determines if a property key is a has - one relationship .
55,658
public function isInverse ( $ key ) { if ( false === $ this -> isRelationship ( $ key ) ) { return false ; } return $ this -> getMetadata ( ) -> getRelationship ( $ key ) -> isInverse ; }
Determines if a property key is a an inverse relationship .
55,659
public function remove ( $ key , Model $ model ) { if ( false === $ this -> isHasMany ( $ key ) ) { return $ this ; } if ( true === $ this -> isInverse ( $ key ) ) { throw ModelException :: cannotModifyInverse ( $ this , $ key ) ; } $ this -> touch ( ) ; $ collection = $ this -> hasManyRelationships -> get ( $ key ) ; ...
Removes a specific Model from a has - many relationship collection .
55,660
protected function getRelationship ( $ key ) { if ( true === $ this -> isHasOne ( $ key ) ) { $ this -> touch ( ) ; return $ this -> hasOneRelationships -> get ( $ key ) ; } if ( true === $ this -> isHasMany ( $ key ) ) { $ this -> touch ( ) ; $ collection = $ this -> hasManyRelationships -> get ( $ key ) ; if ( $ coll...
Gets a relationship value .
55,661
protected function setHasOne ( $ key , Model $ model = null ) { if ( true === $ this -> isInverse ( $ key ) ) { throw ModelException :: cannotModifyInverse ( $ this , $ key ) ; } if ( null !== $ model ) { $ this -> validateRelSet ( $ key , $ model -> getType ( ) ) ; } $ this -> touch ( ) ; $ this -> hasOneRelationships...
Sets a has - one relationship .
55,662
protected function setRelationship ( $ key , $ value ) { if ( true === $ this -> isHasOne ( $ key ) ) { return $ this -> setHasOne ( $ key , $ value ) ; } if ( true === $ this -> isHasMany ( $ key ) ) { throw new \ RuntimeException ( 'You cannot set a hasMany relationship directly. Please access using push(), clear(), ...
Sets a relationship value .
55,663
public function setSecretKey ( $ secretKey ) { $ this -> secretKey = "-----BEGIN PUBLIC KEY-----" . PHP_EOL . chunk_split ( $ secretKey , 64 , PHP_EOL ) . "-----END PUBLIC KEY-----" ; $ this -> checkKey ( ) ; return $ this ; }
Sets or gets your secret key
55,664
private function checkKey ( ) { $ keyResource = openssl_get_publickey ( $ this -> secretKey ) ; $ details = openssl_pkey_get_details ( $ keyResource ) ; if ( ! isset ( $ details [ "key" ] ) || $ details [ "type" ] !== OPENSSL_KEYTYPE_RSA ) { throw new AppException ( "Provided Secret Key is invalid" ) ; } }
Check the key
55,665
public function getContainer ( $ container , $ include_files = true , $ include_folders = true , $ full_tree = false ) { $ this -> checkConnection ( ) ; $ result = $ this -> getFolder ( $ container , '' , $ include_files , $ include_folders , $ full_tree ) ; return $ result ; }
Gets all properties of a particular container if options are false otherwise include content from the container
55,666
public function createEnvironmentFile ( $ reset ) { $ path = app ( ) -> environmentFilePath ( ) ; $ shouldCreateFile = ! file_exists ( $ path ) || $ reset ; if ( $ shouldCreateFile ) { $ description = 'Creating environment file' ; $ this -> output -> write ( '<comment>' . $ description . '...</comment> ' ) ; copy ( bas...
Create the . env from . env . example .
55,667
protected function runCommand ( $ command , $ description ) { $ call = $ this -> output -> isVerbose ( ) ? 'call' : 'callSilent' ; $ write = $ this -> output -> isVerbose ( ) ? 'writeln' : 'write' ; $ this -> output -> { $ write } ( '<comment>' . $ description . '...</comment> ' ) ; $ this -> { $ call } ( $ command ) ;...
Run an Artisan command .
55,668
public function chooseEnvironmentVariable ( $ key , $ question = null , array $ choices ) { $ question = is_null ( $ question ) ? 'Set a value for ' . $ key . ':' : $ question ; $ currentValue = env ( $ key ) ; if ( ! in_array ( $ currentValue , $ choices ) ) { array_unshift ( $ choices , $ currentValue ) ; } $ value =...
Choose an environment variable from a list .
55,669
public function setEnvironmentVariable ( $ key , $ question = null ) { $ question = is_null ( $ question ) ? 'Set a value for ' . $ key . ':' : $ question ; $ currentValue = env ( $ key ) ; $ value = $ this -> askWithCompletion ( $ question , [ $ currentValue ] , $ currentValue ) ; $ this -> writeEnvironmentVariable ( ...
Ask the user for the given environment variable .
55,670
protected function reloadEnvironment ( ) { ( new Dotenv ( app ( ) -> environmentPath ( ) , app ( ) -> environmentFile ( ) ) ) -> overload ( ) ; $ loader = new LoadConfiguration ; $ this -> callSilent ( 'config:clear' ) ; $ loader -> bootstrap ( app ( ) ) ; }
Reload the application & config after making changes .
55,671
private function cleanRoute ( ) { $ uri = "" ; if ( strlen ( $ this -> route ) > 0 && $ this -> route != "/" ) { $ first = substr ( $ this -> route , 0 , 1 ) ; $ last = substr ( $ this -> route , - 1 ) ; if ( $ first != "/" ) { $ uri = "/" ; } $ uri .= $ this -> route ; if ( $ last == "/" ) { $ uri = substr ( $ uri , 0...
cleanRoute function .
55,672
private function getRoute ( ) { $ route = $ this -> route ; $ first = substr ( $ route , 0 , 1 ) ; $ last = substr ( $ route , - 1 ) ; if ( $ first == "/" ) { $ route = substr ( $ route , 1 ) ; } if ( $ last == "/" ) { $ route = substr ( $ route , 0 , - 1 ) ; } $ this -> resource = $ route ; }
getRoute function .
55,673
private function getPath ( ) { $ path = "" ; if ( strlen ( $ this -> path ) > 0 ) { $ path = $ this -> path ; } else { $ path = $ this -> route ; } if ( substr ( $ path , - 1 ) !== "/" ) { $ path .= "/" ; } $ this -> path = $ path ; }
getPath function .
55,674
protected function hostNameForConfigFile ( $ server_name = null , $ server = null ) { $ server_name = $ server_name ? $ server_name : $ this -> getServerName ( ) ; $ server = $ server ? $ server : $ this -> getServer ( ) ; $ this -> checkServerName ( $ server_name ) ; $ this -> checkServer ( $ server ) ; return snake_c...
hostname for config file .
55,675
protected function getCanonicalUrl ( Request $ request ) { return $ this -> urlGenerator -> generate ( $ request -> attributes -> get ( '_route' ) , $ request -> attributes -> get ( '_route_params' ) , UrlGeneratorInterface :: ABSOLUTE_URL ) ; }
Get canonical URL
55,676
public function assertIsNumeric ( $ value , $ message = '%s must be a number and not empty' , $ exception = 'Asserts' ) { if ( is_numeric ( $ value ) === false ) { $ this -> throwException ( $ exception , $ message , $ value ) ; } }
Verifies that the specified condition is numeric and non empty . The assertion fails if the condition is not numeric or empty numeric .
55,677
public function getConfigFilePath ( ) { $ path = null ; $ locator = $ this -> config -> getLocator ( ) ; if ( is_array ( $ this -> file ) ) { $ res = null ; foreach ( $ this -> file as $ file ) { if ( ( $ res = $ locator -> locate ( $ file ) ) !== false ) { break ; } } $ path = $ res -> getPath ( ) ; } else { $ path = ...
Get path to actual config file
55,678
public function read ( $ size = - 1 , $ offset = 0 , array $ headers = array ( ) , \ SplFileObject $ buffer = null ) { $ this -> validateName ( ) ; if ( $ size > 0 ) { $ headers [ 'Range' ] = sprintf ( 'bytes=%d-%d' , $ offset , ( $ offset + $ size ) - 1 ) ; } $ response = $ this -> container -> getConnection ( ) -> ma...
Read the content from the remote storage object .
55,679
public function syncMetadata ( ) { $ this -> validateName ( ) ; if ( ! empty ( $ this -> metadata ) || ! empty ( $ this -> headers ) ) { $ headers = $ this -> getNewHeaders ( ) ; $ headers [ 'Content-Length' ] = '0' ; $ response = $ this -> container -> getConnection ( ) -> makeRequest ( Client :: POST , array ( $ this...
Commits the metadata and custom headers to the remote storage system .
55,680
public function syncManifest ( ) { $ this -> validateName ( ) ; if ( $ this -> manifest ) { $ headers = $ this -> getNewHeaders ( ) ; $ headers [ 'Content-Length' ] = '0' ; $ this -> container -> getConnection ( ) -> makeRequest ( Client :: PUT , array ( $ this -> container -> getName ( ) , $ this -> name ) , $ headers...
Commits the manifest to the remote storage system .
55,681
public function purgeFromCdn ( $ email = null ) { if ( ! $ this -> container -> getConnection ( ) -> getCdnEnabled ( ) ) { throw new Exceptions \ CDNNotEnabled ( ) ; } $ headers = array ( ) ; if ( null !== $ email ) { $ headers [ 'X-Purge-Email' ] = $ email ; } $ this -> container -> getConnection ( ) -> makeCdnRequest...
Purge Edge cache for this object .
55,682
protected function validateName ( $ name = null ) { if ( null == $ name ) { $ name = $ this -> name ; } if ( strlen ( $ name ) > OBJECT_NAME_LIMIT ) { throw new Exceptions \ InvalidObjectName ( ) ; } }
Validates the object name .
55,683
protected function getNewHeaders ( ) { $ headers = array ( 'Content-Length' => ( null !== $ this -> size ) ? strval ( $ this -> size ) : '0' , ) ; if ( null !== $ this -> manifest ) { $ headers [ 'X-Object-Manifest' ] = $ this -> manifest ; } if ( null !== $ this -> etag ) { $ headers [ 'ETag' ] = $ this -> etag ; } if...
Returns array representing http headers based on the respective instance attributes .
55,684
protected function requireClasses ( ) { foreach ( $ this -> classes as $ classPath => $ className ) { $ className = '\\' . ltrim ( $ className , '\\' ) ; if ( file_exists ( $ classPath ) && ! preg_match ( '/\/api\/generated\//' , $ className ) && ! preg_match ( '/activerecord\/dbQuery/' , $ className ) && ! preg_match ...
Require module classes
55,685
public function checkIsContainerConfigurable ( ) { foreach ( $ this -> classes as $ classPath => $ className ) { $ reflectionClass = new \ ReflectionClass ( $ className ) ; if ( in_array ( $ this :: $ containerConfigurableInterface , $ reflectionClass -> getInterfaceNames ( ) , true ) ) { $ this -> isContainerConfigura...
Check if class configures the container
55,686
protected function _validateLanguageCode ( $ langCode ) { if ( ! $ this -> _langHelper -> validateLanguageCode ( $ langCode ) ) { throw Mage :: exception ( 'Radial_Core' , $ this -> _coreHelper -> __ ( self :: INVALID_LANGUAGE_CODE_MESSAGE ) ) ; } return $ this ; }
Check that the language code value is a valid language code . If it is not throw an exception .
55,687
protected function call_closure ( $ closure , array $ parameters = [ ] ) { if ( $ closure instanceof Closure ) { $ rc = new ReflectionFunction ( $ closure ) ; $ args = $ rc -> getParameters ( ) ; } else if ( $ closure instanceof ReflectionClass ) { $ rc = $ closure ; if ( $ constructor = $ rc -> getConstructor ( ) ) { ...
Call closure .
55,688
public function is_singleton ( $ id ) { if ( ! is_string ( $ id ) ) { throw new InvalidArgumentException ( 'Invalid argument. Must be string.' ) ; } if ( ! $ this -> bound ( $ id ) ) { return false ; } $ id = $ this -> get_class_prefix ( $ id ) ; return $ this -> bindings [ $ id ] [ 'singleton' ] === true ; }
Determine if a given type is a singleton or not .
55,689
public function remove ( $ id ) { $ id = $ this -> get_class_prefix ( $ id ) ; unset ( $ this -> keys [ $ id ] , $ this -> bindings [ $ id ] ) ; }
Unset value by identifier .
55,690
protected function getConnection ( Configuration $ config ) { $ connection = $ this -> getOption ( 'connection' ) ; switch ( true ) { case is_array ( $ connection ) : $ connection = new Connection ( array_key_exists ( 'server' , $ connection ) ? $ connection [ 'server' ] : null , array_key_exists ( 'options' , $ connec...
Create MongoDB Connection .
55,691
protected function getLoggerCallable ( ) { if ( ! is_callable ( $ this -> loggerCallable ) ) { $ loggerCallable = $ this -> getOption ( 'logger_callable' ) ; if ( is_callable ( $ loggerCallable ) ) { $ this -> loggerCallable = $ loggerCallable ; } } return $ this -> loggerCallable ; }
Retrieve logger callable .
55,692
protected function addColumn ( $ name , $ null , $ default , $ type , $ size , $ auto , $ unsigned ) { $ this -> columns [ $ name ] = [ 'name' => $ name , 'null' => $ null , 'default' => $ default , 'type' => $ type , 'size' => $ size , 'auto' => $ auto , 'unsigned' => $ unsigned ] ; }
Adds a column to columnslist
55,693
protected function addIndex ( $ name , $ type , $ column ) { if ( isset ( $ this -> indexes [ $ name ] ) ) { $ this -> indexes [ $ name ] [ 'columns' ] [ ] = $ column ; } else { $ this -> indexes [ $ name ] = [ 'name' => $ name , 'type' => $ type , 'columns' => [ $ column ] ] ; } }
Adds an index to the indexlist .
55,694
public function addBuilder ( ManagerBuilder $ builder ) { $ builderName = ( string ) $ builder -> getName ( ) ; if ( $ builderName === '' ) { throw new \ RuntimeException ( 'Only named manager builders allowed' ) ; } if ( array_key_exists ( $ builderName , $ this -> builders ) ) { throw new \ RuntimeException ( sprintf...
Add builder .
55,695
public function removeBuilder ( ManagerBuilder $ builder ) { $ builderName = ( string ) $ builder -> getName ( ) ; if ( $ builderName === '' ) { throw new \ RuntimeException ( 'Only named manager builders allowed' ) ; } if ( array_key_exists ( $ builderName , $ this -> builders ) ) { unset ( $ this -> builders [ $ buil...
Remove registered builder .
55,696
public function initTasks ( array $ config ) { foreach ( $ config as $ taskName => $ taskConfig ) { $ this -> initTask ( $ taskName , $ taskConfig ) ; } }
Initialize the tasks
55,697
protected function initTask ( $ taskName , array $ taskConfig ) { if ( false === isset ( $ taskConfig [ 'script' ] ) ) { $ taskConfig [ 'script' ] = $ this -> defaultScript ; } try { $ task = new Task ( $ taskName , $ taskConfig ) ; $ this -> tasks [ $ taskName ] = $ task ; } catch ( \ Exception $ e ) { $ this -> getLo...
Initialize a single task
55,698
public function forkTask ( Task $ task ) { $ cronExpression = $ task -> getCronExpression ( ) ; if ( true === $ cronExpression -> isDue ( ) ) { $ this -> getLogger ( ) -> info ( sprintf ( 'Starting cron task "%s"' , $ task -> getName ( ) ) , array ( 'command' => $ task -> getCommandToExecute ( ) ) ) ; $ taskProcess = n...
Create a child process for a Task
55,699
public function init ( ) { $ event = new ContextPaneEvent ( $ this ) ; $ this -> dispatcher -> dispatch ( ContextPaneEvent :: EVENT_INIT , $ event ) ; }
Lazy initialise the object