idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
12,000
public function searchPaths ( ) : self { if ( $ this -> options [ 'rootDir' ] === null ) { $ this -> options [ 'rootDir' ] = $ this -> searchRootDir ( ) ; } if ( $ this -> options [ 'vendorDir' ] === null ) { $ this -> options [ 'vendorDir' ] = $ this -> searchVendorDir ( ) ; } return $ this ; }
Search the root and vendor paths if they are not declared .
12,001
public function checkPaths ( ) : self { if ( empty ( $ this -> options [ 'rootDir' ] ) ) { $ this -> options [ 'rootDir' ] .= '/' ; } else { $ rootDirPosLastChar = strlen ( $ this -> options [ 'rootDir' ] ) - 1 ; if ( $ this -> options [ 'rootDir' ] [ $ rootDirPosLastChar ] !== '/' ) { $ this -> options [ 'rootDir' ] ....
Check root and vendor path declared or found .
12,002
private function removeColumnsFromEntity ( ) { $ del = $ this -> getDeletes ( ) ; if ( $ del ) { foreach ( $ del as $ id => $ meta ) { $ this -> dropKeysFromColumnRemoved ( $ id , $ meta ) ; $ sql = new SqlCommand ( ) ; $ sql -> exeCommand ( "ALTER TABLE " . PRE . $ this -> entity . " DROP COLUMN " . $ meta [ 'column' ...
Remove colunas que existiam
12,003
public function contains ( callable $ callback ) { foreach ( array_keys ( $ this -> storage ) as $ priority ) { if ( false !== ( $ index = array_search ( $ callback , $ this -> storage [ $ priority ] , true ) ) ) { return true ; } } return false ; }
Check if the queue contains a specified callback .
12,004
public function export ( ) { $ priorities = array_keys ( $ this -> storage ) ; rsort ( $ priorities , SORT_NUMERIC ) ; $ callbacks = [ ] ; foreach ( $ priorities as $ priority ) { $ callbacks = array_merge ( $ callbacks , $ this -> storage [ $ priority ] ) ; } return $ callbacks ; }
Export the queue as a sorted array .
12,005
public function add ( $ candidate ) { $ hash = $ this -> objectHash ( $ candidate ) ; if ( isset ( $ this -> candidateIds [ $ hash ] ) ) { return $ this ; } $ function = $ this -> shouldCallReversed ( ) ? 'array_unshift' : 'array_push' ; $ function ( $ this -> candidates , $ this -> checkAndReturn ( $ candidate ) ) ; $...
Add a candidate to the chain .
12,006
public function remove ( $ candidate ) { $ hash = $ this -> objectHash ( $ candidate ) ; $ this -> candidates = array_filter ( $ this -> candidates , function ( $ known ) use ( $ hash ) { return $ this -> objectHash ( $ known ) != $ hash ; } ) ; if ( isset ( $ this -> candidateIds [ $ hash ] ) ) { unset ( $ this -> can...
Remove a candidate from the chain .
12,007
protected function checkAndReturn ( $ candidate ) { if ( ! is_object ( $ candidate ) ) { throw new InvalidArgumentException ( 'Only objects are supported not ' . gettype ( $ candidate ) ) ; } $ type = $ this -> getCandidateType ( ) ; if ( $ candidate instanceof $ type ) { return $ candidate ; } $ thisClass = get_class ...
Check the type of the extension and return it .
12,008
protected function detectType ( ) { if ( property_exists ( $ this , 'allow' ) ) { return $ this -> allow ; } $ interfaces = ( new ReflectionClass ( $ this ) ) -> getInterfaceNames ( ) ; if ( $ interfaces ) { return $ interfaces [ 0 ] ; } return get_class ( $ this ) ; }
Try to guess the type of its candidates . First look for an property allow . If this is not set search the interfaces finally just return the class of this object .
12,009
final public function run ( int $ argc , array $ argv ) { $ ar = new ArgsManager ( ) ; $ ar -> getArgs ( $ argc , $ argv ) ; }
Run manager console
12,010
private function shouldExecuteCallback ( $ msg ) { if ( $ this -> pattern ) { return ( bool ) preg_match ( $ this -> pattern , $ msg , $ this -> matches ) ; } return true ; }
Tests the pattern against the given string .
12,011
public function setBannedWordsTable ( $ table ) { if ( is_string ( $ table ) ) { $ this -> banned_words_table = filter_var ( $ table , FILTER_SANITIZE_STRING ) ; } return $ this ; }
Sets the name of the table where the list of banned words should be located
12,012
public function containsBlockedWord ( $ text ) { if ( ! is_array ( $ this -> blockedWords ) ) { $ this -> getBlockedWords ( ) ; } foreach ( $ this -> blockedWords as $ words ) { if ( strpos ( strtolower ( $ text ) , strtolower ( $ words [ 'word' ] ) ) !== false ) { return true ; } } return false ; }
Checks to see if the string given contains any of the banned words
12,013
public function addBlockedWord ( $ text ) { if ( ! $ this -> db -> count ( $ this -> getBannedWordsTable ( ) , array ( 'word' => strtolower ( $ text ) ) ) ) { return $ this -> db -> insert ( $ this -> getBannedWordsTable ( ) , array ( 'word' => strtolower ( $ text ) ) ) ; } return false ; }
Adds a word to the blocked list used to detect spam
12,014
public function getBlockedWords ( $ search = '' ) { $ where = array ( ) ; if ( ! empty ( $ search ) ) { $ where [ 'word' ] = array ( 'LIKE' , '%' . $ search . '%' ) ; } $ this -> blockedWords = $ this -> db -> selectAll ( $ this -> getBannedWordsTable ( ) , $ where ) ; return $ this -> blockedWords ; }
Lists all of the blocked words within the database
12,015
public function setDataRow ( string $ attributeId , string $ itemId , string $ language , int $ row , int $ col , string $ value ) : void { $ queryBuilder = $ this -> connection -> createQueryBuilder ( ) -> insert ( 'tl_metamodel_translatedtabletext' ) ; $ queryBuilder -> values ( [ 'tstamp' => ':tstamp' , 'value' => '...
Store a cell in the database .
12,016
public function getQueueArn ( $ queueUrl ) { $ queueArn = strtr ( $ queueUrl , array ( 'http://' => 'arn:aws:' , 'https://' => 'arn:aws:' , '.amazonaws.com' => '' , '/' => ':' , '.' => ':' , ) ) ; if ( substr ( $ queueArn , - 5 ) === ':fifo' ) { $ queueArn = substr_replace ( $ queueArn , '.fifo' , - 5 ) ; } return $ qu...
Converts a queue URL into a queue ARN .
12,017
public static function getConfiguration ( ) : array { $ projectConfig = ( array ) self :: getProjectConfigurationValues ( ) ; $ addonConfig = self :: getAddonConfigurationValues ( ) ; return array_merge ( $ projectConfig , $ addonConfig ) ; }
Get the project s full configuration including those for the project and included addons .
12,018
public static function getBundle ( string $ bundleId ) { if ( ! array_key_exists ( $ bundleId , self :: $ runtimeBundles ) ) { return null ; } $ bundle = & self :: $ runtimeBundles [ $ bundleId ] ; $ bundle -> link = Request :: getLocationUrl ( Output :: DEFAULT_BUNDLE_PATH_PREFIX . '/' . $ bundleId ) ; if ( empty ( $ ...
Retrieve a bundle .
12,019
public static function registerBundle ( string $ bundleId , \ stdClass $ bundle ) { $ bundle -> bundleId = $ bundleId ; self :: $ runtimeBundles [ $ bundleId ] = $ bundle ; }
Register a bundle for the current runtime .
12,020
private static function isConfigApplicableToEnvironment ( $ config ) : bool { if ( ! property_exists ( $ config , "environment" ) || empty ( $ config -> environment ) ) { return true ; } $ applicableToEnvs = $ config -> environment ; if ( is_string ( $ applicableToEnvs ) ) { $ applicableToEnvs = explode ( "|" , $ appli...
Check if configuration is applicable to the current environment .
12,021
protected function parseChain ( $ chain ) { $ parts = is_array ( $ chain ) ? $ chain : explode ( '|' , $ chain ) ; $ parsed = [ ] ; foreach ( $ parts as $ name ) { list ( $ operator , $ key ) = $ this -> splitExpression ( $ name ) ; $ dotPos = strpos ( $ key , ':' ) ; list ( $ key , $ parameters ) = $ dotPos ? explode ...
Parses a passed chain into a native format .
12,022
protected function getUnsettedKeys ( ) { $ unsettedKeys = [ ] ; foreach ( $ this -> _originalAttributes as $ key => $ value ) { if ( ! array_key_exists ( $ key , $ this -> _attributes ) ) { $ unsettedKeys [ ] = $ key ; continue ; } } return $ unsettedKeys ; }
Return all unsetted keys . You could set them all to zero in storage .
12,023
public function validate ( SchemaDescriptor $ schema ) { if ( $ prevSchema = SchemaStore :: getPreviousSchema ( $ schema -> getId ( ) ) ) { if ( ! $ prevSchema instanceof SchemaDescriptor ) { throw new \ RuntimeException ( sprintf ( 'Un-parsed schema "%s".' , $ prevSchema [ 'id' ] ) ) ; } foreach ( $ this -> constraint...
Validates a single schema against previous version .
12,024
public function remove ( $ entity ) { $ idAccessorRegistry = $ this -> unitOfWork -> getEntityRegistry ( ) -> getIdAccessorRegistry ( ) ; $ entityId = $ idAccessorRegistry -> getEntityId ( $ entity ) ; $ this -> updateMap ( ) ; if ( ! in_array ( $ entityId , $ this -> map ) ) { throw new EntityNotFoundException ; } $ c...
Deletes an entity from the repo
12,025
private function updateMap ( ) { $ this -> map = $ this -> mapRepository -> findAll ( ) -> columns ( [ $ this -> relation -> colJoinName ( ) ] ) -> getItems ( ) ; }
Update the internal mapping
12,026
public static function getInstance ( ... $ constructorParams ) { $ class = get_called_class ( ) ; if ( isset ( static :: $ instanceOfClass [ $ class ] ) ) { return static :: $ instanceOfClass [ $ class ] ; } static :: $ instanceOfClass [ $ class ] = $ nstnc = new static ( ... $ constructorParams ) ; return $ nstnc ; }
First object instantiated via this method called on current class .
12,027
protected function createPdf ( ) { if ( $ this -> _isCreated ) { return FALSE ; } $ command = $ this -> getCommand ( ) ; $ fileName = $ this -> getPdfFilename ( ) ; $ command -> addArg ( 'merge' ) ; foreach ( $ this -> _options as $ key => $ option ) { if ( is_int ( $ key ) ) { $ command -> addArg ( $ option ) ; } else...
Run the Command to create the tmp PDF file
12,028
public function run ( ) { $ model = new $ this -> modelClass ( ) ; if ( $ this -> scenario ) { $ model -> setScenario ( $ this -> scenario ) ; } if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> validate ( ) ) { foreach ( $ model -> toArray ( ) as $ key => $ value ) { Yii :: $ app -> settings -...
Render the settings form .
12,029
public function send ( AbstractMetric $ metric ) { $ message = $ this -> getMetricMessage ( $ metric ) ; $ this -> flush ( $ message ) ; }
Send a metric to DataDog agent
12,030
protected function getMetricMessage ( AbstractMetric $ metric ) { $ message = "{$metric->getName()}:{$this->getMetricValue($metric)}|{$this->getMetricIndicator($metric)}" ; if ( $ metric -> getSampleRate ( ) < 1 && $ metric -> getSampleRate ( ) > 0 ) { $ message .= '|@' . sprintf ( "%.1f" , $ metric -> getSampleRate ( ...
Builds the metric udp message
12,031
protected function getMetricValue ( AbstractMetric $ metric ) { $ value = $ metric -> getValue ( ) ; $ type = gettype ( $ value ) ; switch ( $ type ) { case 'boolean' : return ( $ value ) ? 'true' : 'false' ; case 'integer' : case 'double' : return strval ( $ value ) ; case 'NULL' : return 'null' ; case 'string' : if (...
Gets the value for datadog
12,032
protected function getMetricIndicator ( AbstractMetric $ metric ) { switch ( $ metric -> getType ( ) ) { case Set :: TYPE : return 's' ; case Gauge :: TYPE : return 'g' ; case Timer :: TYPE : return 'ms' ; case Counter :: TYPE : return 'c' ; case Histogram :: TYPE : return 'h' ; default : throw new \ InvalidArgumentExc...
Returns the metric indicator depending on the metric type
12,033
protected function setBuildfile ( string $ buildfile ) : self { if ( ! is_file ( $ buildfile ) ) { throw new DiagramException ( sprintf ( 'File "%s" is invalid.' , $ buildfile ) ) ; } $ this -> buildfile = $ buildfile ; return $ this ; }
Load buildfile location
12,034
protected function validateOutputLocation ( string $ format , ? string $ output ) : string { $ buildfileInfo = pathinfo ( $ this -> getBuildfile ( ) ) ; if ( empty ( $ output ) ) { $ output = $ buildfileInfo [ 'dirname' ] ; } if ( is_dir ( $ output ) ) { $ output .= DIRECTORY_SEPARATOR . $ buildfileInfo [ 'filename' ] ...
Load PlantUML diagram output location
12,035
public function save ( string $ format , ? string $ output ) { switch ( $ format ) { case self :: FORMAT_PUML : $ content = $ this -> generatePuml ( ) ; break ; case self :: FORMAT_EPS : case self :: FORMAT_PNG : case self :: FORMAT_SVG : $ content = $ this -> generateImage ( $ format ) ; break ; default : throw new Di...
Saves image on disk
12,036
protected function generateImage ( string $ format ) : string { $ url = $ this -> generateUrl ( $ format ) ; $ content = file_get_contents ( $ url ) ; if ( $ content === false ) { $ content = '' ; } return $ content ; }
Retrieves image from Internet
12,037
protected function generatePuml ( ) : string { $ puml = '' ; foreach ( [ self :: XSL_HEADER , self :: XSL_TARGETS , self :: XSL_CALLS , self :: XSL_FOOTER ] as $ xslFile ) { $ puml .= $ this -> transformToPuml ( $ xslFile ) ; } return $ puml ; }
Generate PlantUml code
12,038
public static function getBool ( string $ key , bool $ defaultValue = false , ? string $ app = null ) : bool { return self :: repository ( $ app ) -> getBool ( $ key , $ defaultValue ) ; }
Get boolean .
12,039
public static function apps ( ) : array { self :: initialize ( ) ; $ apps = [ ] ; foreach ( self :: $ repositories as $ name => $ repository ) { $ apps [ ] = $ name ; } return $ apps ; }
Get apps .
12,040
public static function registerApp ( string $ path , ? string $ app = null ) : void { self :: initialize ( ) ; if ( $ app === null ) { $ app = '*' ; } if ( isset ( self :: $ repositories [ $ app ] ) ) { throw new ConfigException ( 'Application ' . $ app . ' already registered.' ) ; } $ path = rtrim ( $ path , '/' ) ; i...
Register app .
12,041
public static function isAppRegistered ( ? string $ app = null ) : bool { self :: initialize ( ) ; if ( $ app === null ) { $ app = '*' ; } return isset ( self :: $ repositories [ $ app ] ) ; }
Is app registered .
12,042
public static function unregisterApp ( ? string $ app = null ) : void { self :: initialize ( ) ; if ( $ app === null ) { $ app = '*' ; } if ( self :: isAppRegistered ( $ app ) ) { unset ( self :: $ repositories [ $ app ] ) ; } }
Unregister app .
12,043
public static function repository ( ? string $ app = null ) : Repository { self :: initialize ( ) ; if ( $ app === null ) { $ app = '*' ; } if ( $ app === '*' && ! isset ( self :: $ repositories [ $ app ] ) ) { $ path = Path :: root ( 'config' ) ; if ( ! is_dir ( $ path ) ) { throw new ConfigException ( 'Path ' . $ pat...
Get repository .
12,044
public static function envBool ( string $ key , bool $ default = false ) : bool { $ value = self :: env ( $ key , $ default ) ; if ( is_string ( $ value ) ) { $ value = strtolower ( $ value ) ; } return in_array ( $ value , [ 1 , true , '1' , 'true' , 'yes' ] ) ; }
Env bool .
12,045
public static function appPath ( ? string $ app = null ) : ? string { self :: initialize ( ) ; if ( $ app === null ) { $ app = '*' ; } if ( isset ( self :: $ repositories [ $ app ] ) ) { return call_user_func ( [ self :: $ repositories [ $ app ] , 'getPath' ] ) ; } return null ; }
App path .
12,046
public static function getPhrase ( int $ code ) : string { if ( isset ( self :: $ response [ $ code ] ) ) { return ( self :: $ response [ $ code ] ) ; } else { throw new Server500 ( new \ ArrayObject ( array ( "explain" => "Http code does not exist" , "solution" => "Please check your http code" ) ) ) ; } }
Get phrase of http code
12,047
public function get ( $ key , array $ replace = [ ] , $ locale = null , $ fallback = true ) { if ( ! $ line = Line :: findByKey ( $ key ) ) { if ( $ page = Page :: findByKey ( $ key ) ) { $ lines = Line :: getValuesByLocaleAndPage ( $ locale , $ key ) ; return ConvertToTree :: fromFlattened ( $ lines , false ) ; } retu...
Get translation for given key from database .
12,048
protected function callAllListeners ( $ abstract , $ instance ) { $ this -> callListeners ( $ abstract , $ instance , $ this -> resolvingListeners ) ; $ this -> callListeners ( $ abstract , $ instance , $ this -> resolvedListeners ) ; }
Calls all resolving and afterResolving listeners .
12,049
public function storeAfterResolvingListener ( $ abstract , $ listener ) { if ( ! isset ( $ this -> resolvedListeners [ $ abstract ] ) ) { $ this -> resolvedListeners [ $ abstract ] = [ ] ; } $ this -> resolvedListeners [ $ abstract ] [ ] = $ listener ; return $ this ; }
Stores a listener in the resolved array .
12,050
protected function iterateListeners ( array $ listeners , $ result ) { foreach ( $ listeners as $ listener ) { call_user_func ( $ listener , $ result , $ this ) ; } }
Remove one level of indention in callListeners ; - ) .
12,051
public function push ( Job $ job , $ queueName = '' ) { if ( ! isset ( $ this -> queues [ $ queueName ] ) ) { $ this -> queues [ $ queueName ] = [ ] ; } $ this -> queues [ $ queueName ] [ ] = $ job ; return Queue :: QUEUED ; }
Create a job entry inside the queue . The returned job has to have a filled id and status .
12,052
public function count ( $ queueName = '' ) { if ( isset ( $ this -> queues [ $ queueName ] ) ) { return count ( $ this -> queues [ $ queueName ] ) ; } return 0 ; }
Return how many jobs are currently in the queue .
12,053
public function pop ( $ queueName = '' ) { if ( ! isset ( $ this -> queues [ $ queueName ] ) ) { return null ; } if ( ! $ this -> queues [ $ queueName ] ) { return null ; } return array_pop ( $ this -> queues [ $ queueName ] ) ; }
Get the next job from the queue and remove it .
12,054
protected function setUntil ( $ until ) { if ( $ until instanceof DateTime ) { $ this -> until = $ until ; return ; } $ this -> until = ( new DateTime ( ) ) -> modify ( '+' . ltrim ( $ until , '+' ) ) ; }
Set inline until
12,055
protected function isActive ( $ action ) { $ id = $ this -> getActionId ( $ action ) ; return ! in_array ( $ id , $ this -> except , true ) && ( empty ( $ this -> only ) || in_array ( $ id , $ this -> only , true ) ) ; }
Returns a value indicating whether the filter is active for the given action .
12,056
public function add ( $ key , $ value ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } if ( ! $ this -> getConnection ( ) -> getClient ( ) -> hset ( $ this -> name , $ key , $ value ) ) { return false ; } $ this -> _data = null ; $ this -> _count =...
Adds an item to the hash
12,057
public function remove ( $ key ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } if ( ! $ this -> getConnection ( ) -> getClient ( ) -> hdel ( $ this -> name , $ key ) ) { return false ; } $ this -> _data = null ; $ this -> _count = null ; return tr...
Removes an item from the hash
12,058
public function getCount ( ) { if ( $ this -> _count === null ) { if ( $ this -> name === null ) { throw new InvalidConfigException ( get_class ( $ this ) . " requires a name!" ) ; } $ this -> _count = $ this -> getConnection ( ) -> getSlave ( ) -> hlen ( $ this -> name ) ; } return $ this -> _count ; }
Gets the number of items in the hash
12,059
public function addHeaders ( array $ headers ) { foreach ( $ headers as $ name => $ value ) { if ( is_numeric ( $ name ) ) { $ this -> parseHeaderLine ( $ value ) ; } else { $ this -> addHeader ( $ name , $ value ) ; } } return $ this ; }
Add multiple headers at once
12,060
private function parseHeaderLine ( $ line ) { $ matches = [ ] ; if ( preg_match ( '/^([^:]+):(.*)$/' , $ line , $ matches ) === 1 ) { $ this -> addHeader ( trim ( $ matches [ 1 ] ) , trim ( $ matches [ 2 ] ) ) ; } }
Parse a plain header line if required
12,061
public function beforeValidate ( ) { $ event = new ModelEvent ; $ this -> trigger ( self :: EVENT_BEFORE_VALIDATE , $ event ) ; return $ event -> isValid ; }
This method is invoked before validation starts . The default implementation raises a beforeValidate event . You may override this method to do preliminary checks before validation . Make sure the parent implementation is invoked so that the event can be raised .
12,062
public function safeAttributes ( ) { $ scenario = $ this -> getScenario ( ) ; $ scenarios = $ this -> scenarios ( ) ; if ( ! isset ( $ scenarios [ $ scenario ] ) ) { return [ ] ; } $ attributes = [ ] ; foreach ( $ scenarios [ $ scenario ] as $ attribute ) { if ( $ attribute [ 0 ] !== '!' ) { $ attributes [ ] = $ attrib...
Returns the attribute names that are safe to be massively assigned in the current scenario .
12,063
protected function loadAllModules ( ) { $ listModules = array_diff ( scandir ( MODULES_DIR ) , [ '.' , '..' ] ) ; foreach ( $ listModules as $ moduleName ) { $ modulePath = realpath ( MODULES_DIR . $ moduleName ) ; if ( ! is_dir ( $ modulePath ) ) { continue ; } $ this -> moduleList -> addModule ( $ moduleName ) ; } $ ...
Read all directories in modules directory and add each module to Modules class . Generate the load tree . Not initialize modules !
12,064
protected function runAllCoreModules ( ) { $ allModules = \ BFW \ Application :: getInstance ( ) -> getConfig ( ) -> getValue ( 'modules' , 'modules.php' ) ; foreach ( $ allModules as $ moduleInfos ) { $ moduleName = $ moduleInfos [ 'name' ] ; $ moduleEnabled = $ moduleInfos [ 'enabled' ] ; if ( empty ( $ moduleName ) ...
Load core modules defined into config bfw file . Only module for controller router database and template only .
12,065
protected function runModule ( string $ moduleName ) { $ app = \ BFW \ Application :: getInstance ( ) ; $ app -> getSubjectList ( ) -> getSubjectByName ( 'ApplicationTasks' ) -> sendNotify ( 'BfwApp_run_module_' . $ moduleName ) ; $ this -> moduleList -> getModuleByName ( $ moduleName ) -> runModule ( ) ; }
Load a module
12,066
public function inflect ( Route $ route ) { $ arguments = $ this -> extractAttributes ( $ route ) ; return $ this -> createDispatch ( $ arguments ) ; }
Returns the controller class name from provided route
12,067
private function extractAttributes ( Route $ route ) { $ arguments = [ 'namespace' => null , 'controller' => null , 'action' => null , 'args' => [ ] ] ; foreach ( array_keys ( $ arguments ) as $ name ) { $ arguments [ $ name ] = array_key_exists ( $ name , $ route -> attributes ) ? $ route -> attributes [ $ name ] : $ ...
Get arguments form route attributes
12,068
private function createDispatch ( array $ arguments ) { $ arguments [ 'controller' ] = $ this -> filterName ( $ arguments [ 'controller' ] ) ; $ data = [ 'className' => ltrim ( "{$arguments['namespace']}" . "\\" . "{$arguments['controller']}" , "\\" ) , 'method' => lcfirst ( $ this -> filterName ( $ arguments [ 'action...
Create a controller dispatch with provided arguments
12,069
private function filterName ( $ name ) { $ name = str_replace ( [ '-' , '_' ] , ' ' , $ name ) ; $ words = explode ( ' ' , $ name ) ; $ filtered = '' ; foreach ( $ words as $ word ) { $ filtered .= ucfirst ( $ word ) ; } return $ filtered ; }
Filters the controller class name
12,070
public function detach ( $ entity ) { $ this -> entityRegistry -> deregisterEntity ( $ entity ) ; $ objectHashId = $ this -> entityRegistry -> getObjectHashId ( $ entity ) ; unset ( $ this -> scheduledForInsertion [ $ objectHashId ] ) ; unset ( $ this -> scheduledForUpdate [ $ objectHashId ] ) ; unset ( $ this -> sched...
Detaches an entity from being managed
12,071
public function registerDataMapper ( $ className , DataMapperInterface $ dataMapper ) { $ index = strtolower ( $ className ) ; $ this -> dataMappers [ $ index ] = $ dataMapper ; }
Registers a data mapper for a class Registering a data mapper for a class will overwrite any previously - set data mapper for that class
12,072
public function scheduleForInsertion ( $ entity ) { $ objectHashId = $ this -> entityRegistry -> getObjectHashId ( $ entity ) ; $ this -> scheduledForInsertion [ $ objectHashId ] = $ entity ; $ this -> entityRegistry -> setState ( $ entity , EntityStates :: QUEUED ) ; }
Schedules an entity for insertion
12,073
protected function checkForChangedRelations ( ) { foreach ( $ this -> entityRegistry -> getEntities ( ) as $ entity ) { $ meta = $ this -> entityRegistry -> getMeta ( $ entity ) ; foreach ( $ meta -> relations [ 'belongsTo' ] as $ relation ) { $ this -> checkBelongsToRelation ( $ entity , $ relation ) ; } foreach ( $ m...
Checks for changed children
12,074
protected function isScheduled ( $ objectHashId ) { return isset ( $ this -> scheduledForInsertion [ $ objectHashId ] ) || isset ( $ this -> scheduledForUpdate [ $ objectHashId ] ) || isset ( $ this -> scheduledForDeletion [ $ objectHashId ] ) ; }
Checks if an object is scheduled
12,075
protected function scheduleRelationForInsertion ( $ root , $ child , $ foreignKey ) { if ( ! $ this -> entityRegistry -> isRegistered ( $ root ) ) { $ this -> scheduleForInsertion ( $ root ) ; } if ( ! $ this -> entityRegistry -> isRegistered ( $ child ) ) { $ this -> scheduleForInsertion ( $ child ) ; } $ isAccessorRe...
Schedules an entity for insertion creating an aggregate root callback
12,076
protected function getValue ( $ object , $ property ) { if ( isset ( $ object -> { $ property } ) ) { return $ object -> { $ property } ; } $ reflectionClass = new ReflectionClass ( $ object ) ; if ( ! $ reflectionClass -> hasProperty ( $ property ) ) { return null ; } $ reflectionProperty = $ reflectionClass -> getPro...
Gets a value from an object
12,077
protected function setValue ( $ object , $ property , $ value ) { $ reflectionClass = new ReflectionClass ( $ object ) ; if ( ! $ reflectionClass -> hasProperty ( $ property ) ) { $ object -> { $ property } = $ value ; return ; } $ reflectionProperty = $ reflectionClass -> getProperty ( $ property ) ; $ reflectionPrope...
Sets the value in an object
12,078
private function checkHasOneRelation ( $ entity , $ relation ) { $ objectHashId = $ this -> entityRegistry -> getObjectHashId ( $ entity ) ; $ varObjName = $ relation -> varObjectName ( ) ; $ varReferenceName = $ relation -> varReferenceName ( ) ; $ currentRelation = $ this -> getValue ( $ entity , $ varObjName ) ; $ o...
Check for changes in a hasOne relation
12,079
private function checkBelongsToRelation ( $ entity , $ relation ) { $ varObjName = $ relation -> varObjectName ( ) ; $ varIdName = $ relation -> varIdName ( ) ; $ currentRelation = $ this -> getValue ( $ entity , $ varObjName ) ; $ originalRelation = $ this -> getValue ( $ this -> entityRegistry -> getOriginal ( $ enti...
Check for changes in a belongsTo relation
12,080
public function current ( ) : string { if ( ! $ this -> Wp -> is_admin ) { return '' ; } return ! empty ( $ _GET [ 'page' ] ) ? $ this -> c :: unslash ( ( string ) $ _GET [ 'page' ] ) : $ this -> now ( ) ; }
Current menu page .
12,081
public function is ( string $ page = '' ) : bool { if ( ! $ this -> Wp -> is_admin ) { return false ; } elseif ( ! ( $ current = $ this -> current ( ) ) ) { return false ; } if ( ! $ page ) { return true ; } if ( $ page [ 0 ] === '/' ) { $ regex = $ page ; } else { $ regex = '/^' . $ this -> c :: wregxFrag ( $ page , '...
Is a menu page?
12,082
public function currentTab ( ) : string { if ( ! $ this -> Wp -> is_admin ) { return '' ; } return ! empty ( $ _GET [ 'tab' ] ) ? $ this -> c :: unslash ( ( string ) $ _GET [ 'tab' ] ) : '' ; }
Current menu page tab .
12,083
public function isTab ( string $ tab = '' ) : bool { if ( ! $ this -> Wp -> is_admin ) { return false ; } elseif ( ! ( $ current = $ this -> current ( ) ) ) { return false ; } elseif ( ! ( $ current_tab = $ this -> currentTab ( ) ) ) { return false ; } if ( ! $ tab ) { return true ; } if ( $ tab [ 0 ] === '/' ) { $ reg...
Is a menu page tab?
12,084
public function currentPostType ( ) : string { if ( ! $ this -> Wp -> is_admin ) { return '' ; } return ! empty ( $ _GET [ 'post_type' ] ) ? $ this -> c :: unslash ( ( string ) $ _GET [ 'post_type' ] ) : $ this -> postTypeNow ( ) ; }
Current menu page post type .
12,085
public function isForPostType ( string $ post_type = '' ) : bool { if ( ! $ this -> Wp -> is_admin ) { return false ; } elseif ( ! ( $ current = $ this -> current ( ) ) ) { return false ; } elseif ( ! ( $ current_post_type = $ this -> currentPostType ( ) ) ) { return false ; } elseif ( ! in_array ( $ current , [ 'post-...
Is a menu page for a post type?
12,086
public function form ( string $ action , array $ args = [ ] ) : Classes \ SCore \ MenuPageForm { return $ this -> App -> Di -> get ( Classes \ SCore \ MenuPageForm :: class , compact ( 'action' , 'args' ) ) ; }
A menu page form class instance .
12,087
public function exists ( $ post_id , string $ key = '' ) : bool { return ( bool ) $ this -> collect ( $ post_id , $ key ) ; }
Meta values exist?
12,088
public function update ( $ post_id , string $ key , $ value , $ where = '' ) { $ post_id = ( int ) ( $ post_id ?? get_the_ID ( ) ) ; if ( ! $ post_id || ! $ key ) { return ; } update_post_meta ( $ post_id , $ this -> key ( $ key ) , $ value , $ where ) ; }
Update meta value .
12,089
public function collect ( $ post_id , string $ key = '' ) : array { $ post_id = ( int ) ( $ post_id ?? get_the_ID ( ) ) ; if ( ! $ post_id ) { return [ ] ; } $ value = get_post_meta ( $ post_id , $ this -> key ( $ key ) , false ) ; return $ value = ! is_array ( $ value ) ? [ ] : $ value ; }
Collect meta values .
12,090
public function set ( $ post_id , string $ key , array $ values ) { $ post_id = ( int ) ( $ post_id ?? get_the_ID ( ) ) ; if ( ! $ post_id || ! $ key ) { return ; } $ this -> unset ( $ post_id , $ key ) ; $ key = $ this -> key ( $ key ) ; foreach ( $ values as $ _value ) { add_post_meta ( $ post_id , $ key , $ _value )...
Set meta values .
12,091
public function unset ( $ post_id , string $ key ) { $ post_id = ( int ) ( $ post_id ?? get_the_ID ( ) ) ; if ( ! $ post_id || ! $ key ) { return ; } delete_post_meta ( $ post_id , $ this -> key ( $ key ) ) ; }
Unset meta values .
12,092
public function onWpLoaded ( ) { if ( $ this -> c :: isCli ( ) ) { return ; } $ WP_Rewrite = $ GLOBALS [ 'wp_rewrite' ] ; if ( ! empty ( $ _REQUEST [ $ this -> var ] ) ) { $ transient_hash = ( string ) $ _REQUEST [ $ this -> var ] ; } elseif ( mb_stripos ( $ _SERVER [ 'REQUEST_URI' ] ?? '' , '/' . $ this -> slug . '/' ...
Transient redirects .
12,093
public function loginAs ( int $ user_id , bool $ remember = false ) : bool { if ( ! $ user_id ) { return false ; } $ on_set_auth_cookie = function ( string $ value ) { $ _COOKIE [ is_ssl ( ) ? SECURE_AUTH_COOKIE : AUTH_COOKIE ] = $ value ; } ; $ on_set_logged_in_cookie = function ( string $ value ) { $ _COOKIE [ LOGGED...
Log in as a specific WP user .
12,094
final public static function checkUidieExist ( string $ uidie ) : bool { AbstractServer :: checkFileLogExist ( FEnv :: get ( "framework.logs.dev.file" ) ) ; AbstractServer :: checkFileLogExist ( FEnv :: get ( "framework.logs.prod.file" ) ) ; $ fdev = new FileListener ( ) ; $ fprod = new FileListener ( ) ; $ logs_dev = ...
Check if UIDIE exist in logs files
12,095
final public static function generateUidie ( ) : string { $ str = "i" ; $ str .= chr ( rand ( 65 , 90 ) ) ; $ str .= time ( ) ; $ uniqid = substr ( uniqid ( "X" ) , 5 ) ; $ str .= substr ( $ uniqid , 5 ) ; return ( $ str ) ; }
Generate an unique identifier of iumio Exeception
12,096
final public static function getClientIp ( ) : string { if ( isset ( $ _SERVER [ 'HTTP_CLIENT_IP' ] ) ) { return $ _SERVER [ 'HTTP_CLIENT_IP' ] ; } elseif ( isset ( $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ) ) { return $ _SERVER [ 'HTTP_X_FORWARDED_FOR' ] ; } else { return ( isset ( $ _SERVER [ 'REMOTE_ADDR' ] ) ? $ _SERVE...
Get ip client
12,097
final public static function errorHandler ( string $ err_no , string $ err_msg , string $ errfile , string $ errline ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => $ err_msg , "type_error" => self :: errorMap ( $ err_no ) , "line_error" => $ errline , "file_error" => $ errfile ) ) ) ; }
Set iumio framework custom handler
12,098
final public static function shutdownFunctionHandler ( ) { $ lasterror = error_get_last ( ) ; if ( ! FEnv :: isset ( "framework.env" ) ) { die ( $ lasterror [ 'message' ] ) ; } if ( isset ( $ lasterror [ 'type' ] ) == true ) { if ( $ lasterror [ 'type' ] === E_ERROR ) { $ mess = explode ( "Stack trace" , $ lasterror [ ...
Set shutdown handler
12,099
final public static function exceptionHandler ( \ Throwable $ exception ) { if ( FEnv :: isset ( "framework.env" ) ) { throw new Server500 ( new \ ArrayObject ( array ( "explain" => $ exception -> getMessage ( ) , "trace" => $ exception -> getTrace ( ) , "line_error" => $ exception -> getLine ( ) , "file_error" => $ ex...
Set exception handler