idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
30,800
public function dispatch ( $ request , $ ignore_qs = false ) { if ( strpos ( $ request , '#' ) !== false ) { $ request = substr ( $ request , 0 , strpos ( $ request , '#' ) ) ; } if ( $ ignore_qs && strpos ( $ request , '?' ) !== false ) { $ request = substr ( $ request , 0 , strpos ( $ request , '?' ) ) ; } if ( $ this -> router === null ) { throw new BadMethodCallException ( "You are missing a router. Set a router" ) ; } $ bindings = $ this -> router -> toArray ( ) ; $ routes = array_keys ( $ bindings ) ; $ lot_size = ( ( int ) self :: $ ROUTES_PER_LOT ) > 0 ? ( ( int ) self :: $ ROUTES_PER_LOT ) : 35 ; $ chunks = array_chunk ( $ routes , $ lot_size ) ; foreach ( $ chunks as $ pack ) { $ as_one_regex = self :: asJoinedRegex ( $ pack ) ; preg_match_all ( $ as_one_regex , $ request , $ one_regex ) ; $ matched = self :: clearNonMatched ( $ one_regex ) ; $ compiled = self :: compileFound ( $ pack , $ matched ) ; $ bound_key = key ( $ compiled ) ; if ( $ bound_key === null ) { continue ; } $ bound = $ bindings [ $ bound_key ] ; $ vars = array_pop ( $ compiled ) ; $ request_object = ( ( object ) $ vars ) ; if ( $ bound_key !== null ) { return call_user_func ( $ bound , $ request_object ) ; } } return $ this -> fail ( $ request ) ; }
Dispatch a request against the routes held by the router
30,801
private static function compileFound ( $ routes , $ matched ) { $ route_vars = [ ] ; foreach ( $ routes as $ pos => $ raw ) { $ root = "R$pos" ; if ( isset ( $ matched [ $ root ] ) ) { $ root_length = strlen ( $ root ) ; $ route_vars [ $ routes [ $ pos ] ] = [ ] ; foreach ( $ matched as $ key => $ match ) { if ( ! is_numeric ( $ key ) && $ key !== $ root && $ key !== 'all_urls' ) { $ new_key = substr ( $ key , $ root_length + 1 ) ; $ route_vars [ $ routes [ $ pos ] ] [ $ new_key ] = array_pop ( $ match ) ; } } } } return $ route_vars ; }
Builds an array of found variables as declared by the route
30,802
private static function clearNonMatched ( $ match_results ) { return array_filter ( $ match_results , function ( $ el ) { $ keep = true ; if ( $ el === "" || ( is_array ( $ el ) && empty ( $ el ) ) || $ el === null || $ el === array ( "" ) ) { $ keep = false ; } return $ keep ; } ) ; }
Filter out all botched matches
30,803
private static function compileRegex ( & $ route , $ pos ) { $ re_catch_vars = '/\:([a-zA-Z0-9_]+)/' ; $ re_replace_with = "(?P<R{$pos}V$1>[^/\?]+)" ; $ replacement = preg_replace ( $ re_catch_vars , $ re_replace_with , $ route ) ; return "(?P<R$pos>^$replacement\$)" ; }
Build a route into a trapping regex
30,804
public function fix ( CSConfigInterface $ config , $ dryRun = false , $ diff = false ) { $ changed = array ( ) ; $ fixers = $ config -> getFixers ( ) ; $ this -> stopwatch -> openSection ( ) ; $ fileCacheManager = new FileCacheManager ( $ config -> usingCache ( ) , $ config -> getCacheFile ( ) , $ config -> getRules ( ) ) ; $ checkers = [ ] ; $ messageCacheManager = null ; if ( $ config instanceof ConfigInterface ) { $ checkers = $ config -> getCheckers ( ) ; $ messageCacheManager = new FileMessageCacheManager ( $ config -> usingCache ( ) , $ config -> getCheckerCacheFile ( ) , array_map ( 'get_class' , $ config -> getCheckers ( ) ) ) ; } foreach ( $ config -> getFinder ( ) as $ file ) { if ( $ file -> isDir ( ) || $ file -> isLink ( ) ) { continue ; } $ this -> stopwatch -> start ( $ this -> getFileRelativePathname ( $ file ) ) ; $ relativeFile = $ this -> getFileRelativePathname ( $ file ) ; if ( $ fixInfo = $ this -> fixFile ( $ file , $ fixers , $ dryRun , $ diff , $ fileCacheManager , $ checkers , $ messageCacheManager ) ) { $ changed [ $ relativeFile ] = $ fixInfo ; } elseif ( $ messageCacheManager -> hasMessage ( $ this -> getFileRelativePathname ( $ file ) ) ) { $ changed [ $ relativeFile ] = array ( 'checkMessages' => $ messageCacheManager -> getMessage ( $ relativeFile ) , ) ; } $ this -> stopwatch -> stop ( $ this -> getFileRelativePathname ( $ file ) ) ; } $ this -> stopwatch -> stopSection ( 'fixFile' ) ; return $ changed ; }
Fixes all files for the given finder .
30,805
public function onKernelResponse ( FilterResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ id = $ request -> get ( $ this -> ajaxId ) ; if ( ! $ request -> isXmlHttpRequest ( ) || null === $ id ) { return ; } if ( ! isset ( $ this -> ajaxEvents [ $ id ] ) ) { $ event -> setResponse ( new Response ( ) ) ; return ; } $ ajaxEvent = $ this -> ajaxEvents [ $ id ] ; $ request -> setRequestFormat ( $ ajaxEvent -> getFormat ( ) ) ; $ event -> setResponse ( $ ajaxEvent -> generateResponse ( ) ) ; $ event -> stopPropagation ( ) ; }
If the request is ajax this method find the ajax event corresponding with the ajax id request parameter . She replace the response by the ajax response with the correct format .
30,806
private function mcustom ( $ directives ) { $ e = $ this -> __engine ; foreach ( $ directives as $ directive ) { $ class = new $ directive [ 'class' ] ; $ reflection = new ReflectionMethod ( $ class , 'message' ) ; $ subject = $ directive [ 'class' ] ; $ object = $ this ; if ( $ class -> name ( ) !== false ) { $ name = $ class -> name ( ) ; if ( $ e == 'blade' ) { $ pattern = "/\@$name\((.*?)\)/" ; } else { $ pattern = "/\{\% $name\((.*?)\) \%\}/" ; } } if ( $ class -> directive ( ) !== false ) { $ pattern = $ class -> directive ( ) ; } if ( ! isset ( $ pattern ) ) return ; if ( ( $ class -> directive ( ) === false ) && count ( $ reflection -> getParameters ( ) ) == 0 ) { if ( $ e == 'blade' ) { $ pattern = "/\@$name/" ; } else { $ pattern = "/\{\% $name \%\}/" ; } } if ( count ( $ reflection -> getParameters ( ) ) > 0 ) { $ this -> __cached = preg_replace_callback ( $ pattern , function ( $ match ) use ( $ subject , $ object , $ class , $ pattern ) { return $ object -> persist ( $ match , $ subject , $ class ) ; } , $ this -> __cached ) ; } else { $ this -> __cached = preg_replace_callback ( $ pattern , function ( $ match ) use ( $ subject , $ object , $ class , $ pattern ) { return $ object -> persist ( null , $ subject , $ class , true ) ; } , $ this -> __cached ) ; } } }
Run custom directives
30,807
private function usingDirective ( $ pattern , $ control = false , $ capture = false ) { if ( $ control ) { switch ( $ this -> __engine ) { case 'blade' : return "/\@$pattern\((.*?)\)/" ; break ; case 'modulus' : return $ capture == true ? "/\{\% $pattern\((.*?)\) \%\}/" : "/\{\% $pattern (.*?) \%\}/" ; break ; default : return '' ; break ; } return ; } switch ( $ this -> __engine ) { case 'blade' : return "/\@$pattern/" ; break ; case 'modulus' : return "/\{\% $pattern \%\}/" ; break ; default : return '' ; break ; } }
Return code based on specified engine
30,808
public function setFormat ( $ format ) { if ( ! in_array ( $ format , $ this -> formats ) ) { $ msg = "The '%s' format is not allowed. Try with '%s'" ; throw new InvalidArgumentException ( sprintf ( $ msg , $ format , implode ( "', '" , $ this -> formats ) ) ) ; } $ this -> format = $ format ; return $ this ; }
Set request format .
30,809
public function generateResponse ( ) { $ data = $ this -> getData ( ) ; if ( $ data instanceof \ Closure ) { $ data = $ data ( ) ; } $ encoders = [ new XmlEncoder ( ) , new JsonEncoder ( ) ] ; $ normalizers = [ new GetSetMethodNormalizer ( ) ] ; $ serializer = new Serializer ( $ normalizers , $ encoders ) ; $ response = new Response ( ) ; $ response -> headers -> set ( 'Content-Type' , 'application/' . $ this -> getFormat ( ) ) ; $ response -> setContent ( $ serializer -> serialize ( $ data , $ this -> getFormat ( ) ) ) ; return $ response ; }
Generate the ajax response .
30,810
static public function dumpInstances ( ) { foreach ( static :: $ instances as $ k => $ v ) { echo $ k . ':' . get_class ( $ v ) . ':' ; print_r ( $ v -> getOption ( ) ) ; PHP_EOL ; } }
dump use to debug
30,811
public function getTablePrefix ( ) { if ( isset ( $ this -> options [ 'table_prefix' ] ) ) { $ tablePrefix = $ this -> options [ 'table_prefix' ] ; } else { $ tablePrefix = $ this -> getDb ( ) -> getTablePrefix ( ) ; } return $ tablePrefix ; }
get table prefix
30,812
public function getTableName ( $ includeDbname = false ) { if ( ! isset ( $ this -> options [ 'real_table_name' ] ) || empty ( $ this -> options [ 'real_table_name' ] ) ) { if ( ! isset ( $ this -> options [ 'table_name' ] ) || empty ( $ this -> options [ 'table_name' ] ) ) { throw new Exception ( 'table is not exist:' . get_called_class ( ) ) ; } $ realTableName = $ this -> options [ 'table_name' ] ; if ( strpos ( $ realTableName , '.' ) === false && stripos ( $ realTableName , $ this -> getTablePrefix ( ) ) === false ) { $ realTableName = $ this -> getTablePrefix ( ) . $ realTableName ; } } else { $ realTableName = $ this -> options [ 'real_table_name' ] ; } if ( isset ( $ realTableName ) && strpos ( $ realTableName , '.' ) === false && $ includeDbname ) { $ database = $ this -> getDatabase ( ) ; $ realTableName = ( empty ( $ database ) ? '' : $ database . '.' ) . $ realTableName ; } return $ realTableName ; }
get real table name contain database
30,813
public function setTableName ( $ table ) { if ( strpos ( $ table , '.' ) !== false ) { list ( $ database , $ table ) = explode ( '.' , $ table ) ; if ( $ database ) { $ this -> options [ 'database' ] = $ database ; $ this -> options [ 'real_table_name' ] = $ table ; } } else { $ table = StringHelper :: toClassLastName ( $ table , 'model' ) ; } $ table = StringHelper :: toUnderscoreVariable ( $ table ) ; if ( substr ( $ table , 0 , 1 ) === '#' ) { $ this -> options [ 'real_table_name' ] = $ this -> options [ 'table_name' ] = str_replace ( '#' , '' , $ table ) ; } else { $ this -> options [ 'table_name' ] = preg_replace ( '/^' . static :: getTablePrefix ( ) . '/i' , '' , $ table ) ; } return $ this ; }
set model name . if options database or table_name is not set try to set by name .
30,814
public function getPrimarykey ( $ table = null ) { if ( $ table ) { return $ this -> getDb ( ) -> getPrimaryKey ( $ table ) ; } else { if ( ! isset ( $ this -> options [ 'primary_key' ] ) ) { $ pk = $ this -> getDb ( ) -> getPrimaryKey ( $ this -> getTableName ( ) ) ; $ this -> options [ 'primary_key' ] = $ pk ; } return $ this -> options [ 'primary_key' ] ; } }
get primary key
30,815
public function getUniqueKey ( ) { if ( ! isset ( $ this -> options [ 'unique_key' ] ) ) { $ this -> options [ 'unique_key' ] = null ; } if ( $ this -> options [ 'unique_key' ] && is_string ( $ this -> options [ 'unique_key' ] ) ) { $ this -> options [ 'unique_key' ] = StringHelper :: toArray ( $ this -> options [ 'unique_key' ] , ',' ) ; } return $ this -> options [ 'unique_key' ] ; }
get unique key
30,816
public function getFieldNameByBaseType ( $ base_type ) { $ this -> getTableInfo ( ) ; $ field = null ; if ( isset ( $ this [ 'fields' ] ) ) { if ( isset ( $ this [ 'fields' ] [ $ base_type ] ) ) { $ field = $ base_type ; } foreach ( $ this [ 'fields' ] as $ v ) { if ( isset ( $ v [ 'base_type' ] ) && $ v [ 'base_type' ] == $ base_type ) { $ field = $ v [ 'field_name' ] ; break ; } } } return $ field ; }
find field name by base_type
30,817
public function filterProtectedData ( $ data ) { if ( $ data && isset ( $ this [ 'fields' ] ) && isset ( $ this [ 'protected_fields' ] ) && $ this [ 'protected_fields' ] ) { if ( isset ( $ data [ 0 ] ) || is_numeric ( key ( $ data ) ) ) { foreach ( $ data as $ k => $ v ) { $ data [ $ k ] = static :: filterProtectedData ( $ v ) ; } } else { $ fields = array_keys ( $ this [ 'fields' ] ) ; $ pfields = StringHelper :: toArray ( $ this [ 'protected_fields' ] ) ; foreach ( $ data as $ k => $ v ) { if ( in_array ( $ k , $ fields ) && in_array ( $ k , $ pfields ) ) { unset ( $ data [ $ k ] ) ; } } } } return $ data ; }
ensure remain public data
30,818
public function parse ( $ query = null ) { $ this -> checkQuery ( $ query ) ; return $ this -> getDb ( ) -> setQuery ( $ this -> getQuery ( ) ) -> parse ( ) ; }
parse query to sql not execute sql
30,819
public function getEmptyRecord ( ) { $ data = [ ] ; if ( $ this -> fields ) foreach ( $ this -> fields as $ k => $ v ) { $ data [ $ k ] = '' ; } return static :: formatOutput ( $ data ) ; }
get empty record
30,820
public function service ( $ name ) { if ( ! $ this -> services -> offsetExists ( $ name ) ) { throw new Exception ( sprintf ( Exception :: SERVICE_NOT_EXISTS , $ name ) ) ; } return $ this -> services -> offsetGet ( $ name ) ; }
Get a service .
30,821
public function registerService ( $ className ) { if ( ! class_exists ( $ className ) ) { throw new Exception ( sprintf ( Exception :: SERVICE_CLASS_NOT_EXISTS , $ className ) ) ; } $ service = new $ className ( $ this ) ; if ( ! $ service instanceof Service ) { throw new Exception ( sprintf ( Exception :: NOT_A_SERVICE , $ className ) ) ; } if ( $ this -> services -> offsetExists ( $ service -> name ( ) ) ) { throw new Exception ( sprintf ( Exception :: SERVICE_ALREADY_EXISTS , $ service -> name ( ) ) ) ; } $ this -> services -> offsetSet ( $ service -> name ( ) , $ service ) ; }
Process the registration of one service .
30,822
public function indexAsHash ( ) { $ clouds = $ this -> index ( ) ; $ hash = array ( ) ; foreach ( $ clouds as $ cloud ) { $ hash [ $ cloud -> id ] = $ cloud ; } return $ hash ; }
Returns all clouds in a hash where the hash key is the ID of the cloud
30,823
public function supportsCloudFeature ( $ feature ) { $ retval = false ; foreach ( $ this -> links as $ link ) { if ( $ link -> rel == $ feature ) { $ retval = true ; break ; } } return $ retval ; }
Indicates whether the cloud supports a specified cloud feature determined by the presence or absence of an href in the links list for the cloud .
30,824
public function setClass ( $ class ) { foreach ( $ this -> results as $ name ) { $ this -> columns -> offsetGet ( $ name ) -> setClass ( $ class ) ; } }
Set recommended css class .
30,825
public function setHeader ( $ header ) { foreach ( $ this -> results as $ name ) { $ this -> columns -> offsetGet ( $ name ) -> setHeader ( $ header ) ; } return $ this ; }
Set table header for this column .
30,826
public function challenge ( $ subject , $ ruleSet ) : bool { return ValidateAgainstRuleSet :: getInstance ( $ this ) -> challenge ( $ subject , $ ruleSet ) ; }
Validate by a list of rules .
30,827
public function challengeRecording ( $ subject , $ ruleSet , string $ keyPath = 'root' ) { $ validate_by_rules = new ValidateAgainstRuleSet ( $ this , [ 'recordFailure' => true , ] ) ; $ validate_by_rules -> challenge ( $ subject , $ ruleSet , $ keyPath ) ; $ record = $ validate_by_rules -> getRecord ( ) ; return [ 'passed' => ! $ record , 'record' => $ record , ] ; }
Validate by a list of rules recording validation failures .
30,828
public function empty ( $ subject ) : bool { if ( ! $ subject ) { return $ subject !== '0' ; } if ( is_object ( $ subject ) ) { if ( $ subject instanceof \ Countable ) { return ! count ( $ subject ) ; } if ( $ subject instanceof \ Traversable ) { foreach ( $ subject as $ ignore ) { return false ; } return true ; } if ( $ subject instanceof \ ArrayAccess ) { return false ; } return ! get_object_vars ( $ subject ) ; } return false ; }
Subject is null falsy or array|object is empty .
30,829
public function nonEmpty ( $ subject ) : bool { if ( $ subject instanceof \ ArrayAccess && ! ( $ subject instanceof \ Countable ) && ! ( $ subject instanceof \ Traversable ) ) { return false ; } return ! $ this -> empty ( $ subject ) ; }
Subject is not falsy or array|object is non - empty .
30,830
public function enum ( $ subject , array $ allowedValues ) : bool { if ( ! $ allowedValues ) { throw new InvalidArgumentException ( 'Arg allowedValues is empty.' ) ; } if ( $ subject !== null && ! is_scalar ( $ subject ) ) { return false ; } $ i = - 1 ; foreach ( $ allowedValues as $ allowed ) { ++ $ i ; if ( $ allowed !== null && ! is_scalar ( $ allowed ) ) { throw new InvalidArgumentException ( 'Arg allowedValues bucket ' . $ i . ' type[' . Utils :: getType ( $ allowed ) . '] is not scalar or null.' ) ; } if ( $ subject === $ allowed ) { return true ; } } return false ; }
Compares type strict and allowed values must be scalar or null .
30,831
public function bit ( $ subject ) : bool { if ( is_bool ( $ subject ) ) { return true ; } if ( is_int ( $ subject ) || is_string ( $ subject ) ) { return $ subject == 0 || $ subject == 1 ; } return false ; }
Boolean or integer 0|1 .
30,832
public function digital ( $ subject ) : bool { if ( is_int ( $ subject ) ) { return true ; } if ( ! is_string ( $ subject ) ) { return false ; } return ctype_digit ( '' . $ subject ) ; }
Non - negative integer or stringed integer .
30,833
public function class ( $ subject , string $ className ) : bool { if ( ! $ className ) { throw new InvalidArgumentException ( 'Arg className is empty.' ) ; } return $ subject && is_object ( $ subject ) && is_a ( $ subject , $ className ) ; }
Is object and is of that class or interface or has it as ancestor .
30,834
public function container ( $ subject ) { return is_array ( $ subject ) ? 'array' : ( $ subject && is_object ( $ subject ) ? ( $ subject instanceof \ Traversable ? ( $ subject instanceof \ ArrayAccess ? 'arrayAccess' : 'traversable' ) : 'object' ) : false ) ; }
Array or object .
30,835
public function iterable ( $ subject ) { return is_array ( $ subject ) ? 'array' : ( $ subject && $ subject instanceof \ Traversable ? ( $ subject instanceof \ ArrayAccess ? 'arrayAccess' : 'traversable' ) : false ) ; }
Array or Traversable object .
30,836
public function loopable ( $ subject ) { return is_array ( $ subject ) ? 'array' : ( $ subject && is_object ( $ subject ) ? ( $ subject instanceof \ Traversable ? ( $ subject instanceof \ ArrayAccess ? 'arrayAccess' : 'traversable' ) : ( $ subject instanceof \ ArrayAccess ? false : 'object' ) ) : false ) ; }
Array or Traversable object or non - Traversable non - ArrayAccess object .
30,837
public function keyedArray ( $ subject ) : bool { if ( ! is_array ( $ subject ) ) { return false ; } if ( ! $ subject ) { return true ; } return ! ctype_digit ( join ( '' , array_keys ( $ subject ) ) ) ; }
Empty array or keyed array .
30,838
public function min ( $ subject , $ min ) : bool { if ( ! is_int ( $ min ) && ! is_float ( $ min ) ) { throw new InvalidArgumentException ( 'Arg min type[' . Utils :: getType ( $ min ) . '] is not integer or float.' ) ; } if ( $ subject === null ) { return false ; } return $ subject >= $ min ; }
Numeric minimum .
30,839
public function max ( $ subject , $ max ) : bool { if ( ! is_int ( $ max ) && ! is_float ( $ max ) ) { throw new InvalidArgumentException ( 'Arg max type[' . Utils :: getType ( $ max ) . '] is not integer or float.' ) ; } if ( $ subject === null ) { return false ; } return $ subject <= $ max ; }
Numeric maximum .
30,840
public function range ( $ subject , $ min , $ max ) : bool { if ( ! is_int ( $ min ) && ! is_float ( $ min ) ) { throw new InvalidArgumentException ( 'Arg min type[' . Utils :: getType ( $ min ) . '] is not integer or float.' ) ; } if ( ! is_int ( $ max ) && ! is_float ( $ max ) ) { throw new InvalidArgumentException ( 'Arg max type[' . Utils :: getType ( $ max ) . '] is not integer or float.' ) ; } if ( $ max < $ min ) { throw new InvalidArgumentException ( 'Arg max[' . $ max . '] cannot be less than arg min[' . $ min . '].' ) ; } if ( $ subject === null ) { return false ; } return $ subject >= $ min && $ subject <= $ max ; }
Numeric range .
30,841
public function unicode ( $ subject ) : bool { if ( $ subject === null ) { return false ; } $ v = '' . $ subject ; return $ v === '' ? true : ! ! preg_match ( '/./us' , $ v ) ; }
Valid UTF - 8 .
30,842
public function ascii ( $ subject ) : bool { if ( $ subject === null ) { return false ; } $ v = '' . $ subject ; return $ v === '' ? true : ! ! preg_match ( '/^[[:ascii:]]+$/' , $ v ) ; }
Full ASCII ; 0 - 127 .
30,843
public function asciiPrintable ( $ subject ) : bool { if ( $ subject === null ) { return false ; } $ v = '' . $ subject ; if ( $ v === '' ) { return true ; } if ( ! ( $ filtered = filter_var ( $ v , FILTER_UNSAFE_RAW , FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH ) ) || ! is_string ( $ filtered ) ) { return false ; } return ! strcmp ( $ v , $ filtered ) && ! strpos ( ' ' . $ v , chr ( 127 ) ) ; }
Allows ASCII except lower ASCII and DEL .
30,844
public function alphaNum ( $ subject , string $ case = '' ) : bool { if ( $ subject === null ) { return false ; } $ v = '' . $ subject ; if ( $ v === '' ) { return false ; } switch ( $ case ) { case 'lower' : $ regex = '/^[a-z\d]+$/' ; break ; case 'upper' : $ regex = '/^[A-Z\d]+$/' ; break ; default : $ regex = '/^[a-zA-Z\d]+$/' ; break ; } return ! ! preg_match ( $ regex , $ v ) ; }
ASCII alphanumeric .
30,845
public function dateISO8601Local ( $ subject ) : bool { if ( $ subject === null ) { return false ; } $ v = '' . $ subject ; return strlen ( $ v ) == 10 && ! ! preg_match ( '/^\d{4}\-\d{2}\-\d{2}$/' , $ v ) ; }
ISO - 8601 date without timezone indication .
30,846
public function dateTimeISO8601Local ( $ subject ) : bool { if ( $ subject === null ) { return false ; } $ v = '' . $ subject ; return strlen ( $ v ) <= 19 && ! ! preg_match ( '/^\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}(:\d{2})?$/' , $ v ) ; }
ISO - 8601 datetime without timezone indication .
30,847
public function plainText ( $ subject ) : bool { if ( $ subject === null ) { return false ; } $ v = '' . $ subject ; return $ v === '' ? true : ! strcmp ( $ v , strip_tags ( $ v ) ) ; }
Doesn t contain tags .
30,848
public function setControlIds ( $ controlIds ) { if ( ! is_array ( $ controlIds ) ) { $ controlIds = array ( $ controlIds ) ; } $ this -> controlIds = $ controlIds ; return $ this ; }
Sets the IDs of the controls this event should listen to .
30,849
public static function cancel ( ScopedCallback & $ sc = null ) { if ( $ sc ) { $ sc -> callback = null ; } $ sc = null ; }
Destroy a scoped callback without triggering it .
30,850
public function generateClassMap ( Wsdl $ wsdl ) : string { return $ this -> twig -> render ( 'class-map.html' , [ 'wsdl' => $ wsdl , 'namespace' => $ this -> getNamespace ( ) , ] ) ; }
Generate a class map .
30,851
public function generateStruct ( Struct $ struct ) : string { $ classNamePostfix = '' ; if ( $ struct instanceof Response ) { $ classNamePostfix = 'Response' ; } if ( $ struct instanceof Request ) { $ classNamePostfix = 'Request' ; } return $ this -> twig -> render ( 'struct.html' , [ 'classNamePostfix' => $ classNamePostfix , 'struct' => $ struct , 'namespace' => $ this -> getNamespace ( ) , 'full_namespace' => $ this -> getFullNamespace ( ) ] ) ; }
Generate a single struct
30,852
public function generateService ( Wsdl $ wsdl ) : string { return $ this -> twig -> render ( 'service.html' , [ 'wsdl' => $ wsdl , 'namespace' => $ this -> getNamespace ( ) ] ) ; }
Generate a service class
30,853
public function className ( $ className , $ arguments = null , $ constructor = null ) { $ this -> flush ( ) ; $ this -> className = $ className ; if ( ! is_null ( $ arguments ) && is_array ( $ arguments ) ) { $ this -> getCollection ( ) -> setArguments ( $ className , $ arguments ) ; } if ( ! is_null ( $ constructor ) ) { $ this -> getCollection ( ) -> setConstructor ( $ className , $ constructor ) ; } return $ this ; }
Setter for the name of the class which has dependencies .
30,854
public function dependsOn ( $ className ) { if ( $ this -> currentDependency ) { $ this -> flush ( ) ; } $ this -> currentDependency = clone $ this -> dependency ; $ this -> currentDependency -> setClassName ( $ className ) ; return $ this ; }
Setter for the name of the dependency class .
30,855
public function id ( $ target ) { if ( null === $ this -> currentDependency ) { throw new Doozr_Form_Service_Exception ( sprintf ( 'Please call className() before trying to set an Id via %s' , __METHOD__ ) ) ; } return $ this -> target ( $ target ) ; }
Setter for the target of the dependency class .
30,856
public function store ( $ returnContainer = true ) { $ this -> reset ( ) ; $ this -> container -> setMap ( $ this ) ; if ( $ returnContainer === true ) { return $ this -> container ; } else { return $ this ; } }
Setter for the configuration of the dependency class .
30,857
protected function flush ( ) { $ this -> lastClassName = $ this -> className ; if ( $ this -> currentDependency !== null ) { $ this -> getCollection ( ) -> addDependency ( $ this -> id , $ this -> className , $ this -> constructor , $ this -> currentDependency ) ; } $ this -> currentDependency = null ; }
Flushes the content .
30,858
public function insertAfter ( $ value , $ afterKey ) { $ new_object = new self ( ) ; foreach ( ( array ) $ this -> items as $ k => $ v ) { if ( $ afterKey == $ k ) { $ new_object -> add ( $ value ) ; } $ new_object -> add ( $ v ) ; } $ this -> items = $ new_object -> items ; return $ this ; }
Insert into an object
30,859
private function whereObject ( $ object , $ column , $ operator , $ value = null , $ inverse = false ) { if ( ! $ object -> $ column && $ operator != 'null' ) { return true ; } $ method = 'getWhere' . ucfirst ( $ operator ) ; if ( method_exists ( $ this , $ method ) ) { return $ this -> { $ method } ( $ object , $ column , $ value , $ inverse ) ; } return $ this -> getWhereDefault ( $ object , $ column , $ value , $ inverse ) ; }
Compare the object and column passed with the value using the operator
30,860
protected static function retrieveInstallPath ( ) { $ path1 = DIRECTORY_SEPARATOR . implode ( DIRECTORY_SEPARATOR , array ( 'src' , 'Doozr' , 'Installer' , 'Base.php' ) ) ; $ path2 = DIRECTORY_SEPARATOR . implode ( DIRECTORY_SEPARATOR , array ( 'vendor' , 'clickalicious' , 'doozr' ) ) ; $ path = str_replace ( $ path1 , '' , __FILE__ ) ; $ path = str_replace ( $ path2 , '' , $ path ) ; return realpath ( $ path ) ; }
Returns install path relative to current path .
30,861
protected static function getSourcePath ( ) { $ path = DIRECTORY_SEPARATOR . implode ( DIRECTORY_SEPARATOR , array ( 'src' , 'Doozr' , 'Installer' , 'Base.php' ) ) ; return realpath ( str_replace ( $ path , '' , __FILE__ ) ) . DIRECTORY_SEPARATOR ; }
Detect and return source path containing the bootstrap project structure .
30,862
protected static function showVersion ( ) { \ cli \ line ( ) ; \ cli \ line ( \ cli \ Colors :: colorize ( '%y+----------------------------------------------------------------------+%N' ) ) ; \ cli \ line ( \ cli \ Colors :: colorize ( '%y| Welcome to Doozr\'s Demo project installer. |%N' ) ) ; \ cli \ line ( \ cli \ Colors :: colorize ( '%y| Version: ' . DOOZR_INSTALLER_VERSION . ' |%N' ) ) ; \ cli \ line ( \ cli \ Colors :: colorize ( '%y+----------------------------------------------------------------------+%N' ) ) ; }
Shows Doozr version banner .
30,863
protected static function showVhostExample ( $ installPath ) { \ cli \ line ( ) ; \ cli \ line ( 'You could use this skeleton (example and not production ready!) for your vhost:' ) ; \ cli \ line ( ) ; \ cli \ line ( \ cli \ Colors :: colorize ( '%y<VirtualHost *:80>' ) ) ; \ cli \ line ( ' ServerName www.example.com:80' ) ; \ cli \ line ( ' ServerAlias example.com *.example.com' ) ; \ cli \ line ( ' ServerAdmin webmaster@example.com' ) ; \ cli \ line ( ' DocumentRoot "' . $ installPath . DIRECTORY_SEPARATOR . 'web"' ) ; \ cli \ line ( ' <Directory "' . $ installPath . DIRECTORY_SEPARATOR . 'web">' ) ; \ cli \ line ( ' Options Indexes FollowSymLinks Includes ExecCGI' ) ; \ cli \ line ( ' AllowOverride All' ) ; \ cli \ line ( ' Order allow,deny' ) ; \ cli \ line ( ' Allow from all' ) ; \ cli \ line ( ' DirectoryIndex app.php index.php index.html index.htm' ) ; \ cli \ line ( ' </Directory>' ) ; \ cli \ line ( '</VirtualHost>' ) ; }
Echoes a VHost skeleton with correct path inserted .
30,864
public static function getParam ( $ name ) { if ( $ param = static :: getCont ( ) -> hasParameter ( $ name ) ) { return static :: getCont ( ) -> getParameter ( $ name ) ; } if ( strpos ( $ name , '.' ) !== false ) { $ parts = explode ( '.' , $ name , 2 ) ; $ data = static :: getCont ( ) -> getParameter ( $ parts [ 0 ] ) ; $ data = UtilArray :: cascadeGet ( $ data , $ parts [ 1 ] ) ; if ( $ data ) { return $ data ; } } return static :: getCont ( ) -> getParameter ( $ name ) ; }
Pobieranie parametru .
30,865
public function set ( $ data , $ value = null ) { Argument :: i ( ) -> test ( 1 , 'array' , 'string' ) ; if ( is_array ( $ data ) ) { $ this -> data = $ data ; return $ this ; } $ this -> data [ $ data ] = $ value ; return $ this ; }
Sets template variables
30,866
public function parseString ( $ string ) { Argument :: i ( ) -> test ( 1 , 'string' ) ; foreach ( $ this -> data as $ key => $ value ) { $ string = str_replace ( $ key , $ value , $ string ) ; } return $ string ; }
Simple string replace template parser
30,867
protected function start ( ) { $ args = $ this -> getServerArguments ( ) ; if ( $ args [ 'command' ] ) { $ commandClass = $ this -> getCommandClassFromNameAndModule ( $ args [ 'command' ] , null ) ; } else { $ commandClass = $ this -> notFoundCommand ; } if ( ! class_exists ( $ commandClass ) ) { $ this -> alert ( 'Command ' . $ commandClass . ' not found!' , array ( 'requestedCommand' => $ args [ 'command' ] , 'requestedModule' => '-' ) ) ; $ commandClass = $ this -> notFoundCommand ; } $ command = $ this -> loadCommand ( $ commandClass ) ; $ command -> setActiveAction ( $ args [ 'action' ] ) ; $ command -> run ( $ args [ 'params' ] ) ; }
This is the main method called when the application is executed .
30,868
private function parseArgs ( $ args ) { $ command = $ action = null ; $ params = [ ] ; foreach ( $ args as $ argument ) { if ( '-' != $ argument [ 0 ] ) if ( null === $ command ) $ command = $ argument ; elseif ( null === $ action ) $ action = $ argument ; else $ this -> alert ( 'Invalid argument ' . $ argument . '!' , [ 'command' => $ command , 'action' => $ action , 'serverArguments' => $ _SERVER [ 'argv' ] , 'processedArguments' => $ args ] ) ; else { $ argument = substr ( $ argument , 1 ) ; if ( '-' == $ argument [ 0 ] ) $ argument = substr ( $ argument , 1 ) ; $ argument = explode ( '=' , $ argument , 2 ) ; $ params [ $ argument [ 0 ] ] = isset ( $ argument [ 1 ] ) ? $ argument [ 1 ] : true ; } } return [ 'command' => $ command , 'action' => $ action , 'params' => $ params ] ; }
Receives a list of strings and extracts the command action and parameters from that list .
30,869
private function loadCommand ( $ class ) { $ controller = new $ class ( ) ; if ( ! is_a ( $ controller , '\\mpf\\cli\\Command' ) ) { $ this -> critical ( 'Command `' . $ class . '` must extend \\mpf\\cli\\Command!' , array ( 'requestedController' => $ this -> request ( ) -> getController ( ) , 'requestedModule' => $ this -> request ( ) -> getModule ( ) ) ) ; return null ; } return $ controller ; }
Instantiate command and check if class is correct ;
30,870
public function generate ( $ source = null ) { $ this -> getParser ( ) -> setInput ( [ 'className' => $ source ] ) ; $ this -> addRawDependenciesToCollection ( $ this -> getParser ( ) -> parse ( ) , $ source ) ; }
Builds the collection from dependency parser result for given class .
30,871
public static function get ( $ request , $ match ) { if ( array_key_exists ( 'userId' , $ match ) ) { $ user = Pluf_Shortcuts_GetObjectOr404 ( 'User_Account' , $ match [ 'userId' ] ) ; } else { $ user = $ request -> user ; } if ( $ user -> isAnonymous ( ) ) { throw new Pluf_Exception_BadRequest ( 'User is not defined' ) ; } return User_Shortcuts_GetAvatar ( $ user ) ; }
Returns avatar image of user .
30,872
public static function update ( $ request , $ match ) { if ( array_key_exists ( 'userId' , $ match ) ) { if ( $ request -> user -> id != $ match [ 'userId' ] && ! User_Precondition :: isOwner ( $ request ) ) { throw new Pluf_Exception_Forbidden ( 'Not allowed to change others avatar' ) ; } $ user = Pluf_Shortcuts_GetObjectOr404 ( 'User_Account' , $ match [ 'userId' ] ) ; } else { $ user = $ request -> user ; } if ( $ user -> isAnonymous ( ) ) { throw new Pluf_Exception_BadRequest ( 'User is not defined' ) ; } return User_Shortcuts_UpdateAvatar ( $ user , array_merge ( $ request -> REQUEST , $ request -> FILES ) ) ; }
Updates avatar image of user .
30,873
public static function delete ( $ request , $ match ) { if ( array_key_exists ( 'userId' , $ match ) ) { if ( $ request -> user -> id != $ match [ 'userId' ] && ! User_Precondition :: isOwner ( $ request ) ) { throw new Pluf_Exception_Forbidden ( 'Not allowed to change others avatar' ) ; } $ user = Pluf_Shortcuts_GetObjectOr404 ( 'User_Account' , $ match [ 'userId' ] ) ; } else { $ user = $ request -> user ; } if ( $ user -> isAnonymous ( ) ) { throw new Pluf_Exception_BadRequest ( 'User is not defined' ) ; } return User_Shortcuts_DeleteAvatar ( $ user ) ; }
Deletes avatar images of user . This action may set default avatar for user .
30,874
public function add ( \ Strukt \ Console \ Command $ command ) { $ class = get_class ( $ command ) ; $ docBlockParser = new \ Strukt \ Console \ DocBlockParser ( $ class ) ; $ docList = $ docBlockParser -> parse ( ) ; $ cmdAlias = $ docList [ "command" ] [ "alias" ] ; $ this -> commands [ $ cmdAlias ] [ "object" ] = $ command ; $ this -> commands [ $ cmdAlias ] [ "docparser" ] = $ docBlockParser ; $ this -> commands [ $ cmdAlias ] [ "doclist" ] = $ docList ; if ( $ this -> padlen == 0 || strlen ( $ docList [ "command" ] [ "alias" ] ) > $ this -> padlen ) $ this -> padlen = strlen ( $ docList [ "command" ] [ "alias" ] ) ; }
Add commands to console application
30,875
public function getResultMessage ( Model $ model , $ info = null , $ type = null ) { if ( empty ( $ info ) || ! is_array ( $ info ) ) { return false ; } $ type = ( string ) $ type ; if ( ! empty ( $ type ) ) { $ type = ' ' . $ type ; } $ result = '' ; $ messages = [ ] ; foreach ( $ info as $ infoItem ) { if ( ! isset ( $ infoItem [ 'data' ] ) || empty ( $ infoItem [ 'data' ] ) || ! is_array ( $ infoItem [ 'data' ] ) ) { continue ; } if ( isset ( $ infoItem [ 'deep' ] ) && $ infoItem [ 'deep' ] ) { $ numRecords = count ( $ infoItem [ 'data' ] , COUNT_RECURSIVE ) - count ( $ infoItem [ 'data' ] , COUNT_NORMAL ) ; } else { $ numRecords = count ( $ infoItem [ 'data' ] ) ; } if ( $ numRecords == 0 ) { continue ; } $ numRecordsText = __dn ( 'cake_ldap' , 'record' , 'records' , $ numRecords ) ; $ label = '' ; if ( isset ( $ infoItem [ 'label' ] ) ) { $ label = $ infoItem [ 'label' ] ; } if ( ! empty ( $ label ) ) { $ label .= ': ' ; } $ messages [ ] = ' * ' . $ label . $ numRecords . ' ' . $ numRecordsText ; } if ( ! empty ( $ messages ) ) { $ result = __d ( 'cake_ldap' , 'Result of synchronization' ) . $ type . "\n" . implode ( "\n" , $ messages ) ; } return $ result ; }
Return message of result for synchronization process .
30,876
public function offsetSet ( $ offset , $ value ) : void { if ( $ this instanceof PropertyLimitable ) { if ( ! in_array ( $ offset , $ this -> concreteAttributes ( ) ) ) { throw new \ LogicException ( 'Property not defined as a concrete property.' ) ; } } $ this -> accessableOffsetSet ( $ offset , $ value ) ; }
Set a value if allowed by the concrete attributes .
30,877
public function run ( $ request ) { die ( "FeaturedImageUpdateTask hasn't actually been fully implemented; run() needs to be rewritten to loop over all DataObjects which have been extended with FeaturedImage for this task to actually work" ) ; $ class = $ this -> owner -> class ; $ baseclass = $ this -> ownerBaseClass ; if ( $ baseclass == $ class && array_search ( $ baseclass , DB :: table_list ( ) ) ) { $ rows = DB :: query ( 'SELECT * FROM "' . $ baseclass . '"' ) ; $ altered = false ; foreach ( $ rows as $ page ) { if ( array_key_exists ( 'FeaturedImageID' , $ page ) && $ imageID = $ page [ 'FeaturedImageID' ] ) { DB :: query ( 'INSERT INTO "' . $ baseclass . '_FeaturedImages" (' . $ class . 'ID, ImageID) VALUES (' . $ page [ 'ID' ] . ', ' . $ page [ 'FeaturedImageID' ] . ')' ) ; $ altered = true ; } } if ( $ altered ) { DB :: query ( 'ALTER TABLE "' . $ baseclass . '" DROP "FeaturedImageID"' ) ; DB :: alteration_message ( 'Migrated FeaturedImages to many_many on ' . $ baseclass , 'changed' ) ; } } }
Migrate legacy has_one featured image to many_many relation
30,878
public function setName ( $ name ) { if ( $ this -> getMultiValue ( ) === true ) { $ name .= $ this -> getMultiValueSuffix ( ) ; } return parent :: setName ( $ name ) ; }
Setter for name .
30,879
public function setAttribute ( $ key , $ value = null ) { if ( $ key === 'name' && stristr ( $ value , $ this -> getMultiValueSuffix ( ) ) !== false ) { $ this -> setMultiValue ( true ) ; } parent :: setAttribute ( $ key , $ value ) ; }
Setter for attributes .
30,880
public function logout ( ) { $ this -> _userData = array ( ) ; $ this -> _rights = array ( ) ; $ this -> connected = false ; Session :: get ( ) -> delete ( App :: get ( ) -> shortName . $ this -> sessionKey ) ; Cookie :: get ( ) -> delete ( App :: get ( ) -> shortName . $ this -> cookieKey ) ; Cookie :: get ( ) -> delete ( $ this -> cookieKey ) ; session_destroy ( ) ; }
Logout for current user . It wil clear session and cookie .
30,881
public function setState ( $ name , $ value ) { $ this -> _userData [ $ name ] = $ value ; Session :: get ( ) -> updateListItem ( App :: get ( ) -> shortName . $ this -> sessionKey , 'vars' , $ this -> _userData , array ( 'vars' => array ( ) , 'rights' => array ( ) ) ) ; return $ this ; }
Set user state .
30,882
public function setRights ( $ rights ) { $ this -> _rights = $ rights ; Session :: get ( ) -> updateListItem ( App :: get ( ) -> shortName . $ this -> sessionKey , 'rights' , $ this -> _rights , array ( 'vars' => array ( ) , 'rights' => array ( ) ) ) ; return $ this ; }
Set a new set of rights for active user .
30,883
final function GetNewStatement ( ) { $ result = 'new \\' . get_class ( $ this ) ; $ params = $ this -> GetConstructParams ( ) ; if ( ! is_array ( $ params ) ) { throw new \ Exception ( 'PHP writable class ' . get_class ( $ this ) . ' did not provide an array as construct params' ) ; } $ strParams = array ( ) ; foreach ( $ params as $ param ) { $ strParams [ ] = $ this -> GetParamString ( $ param ) ; } return $ result . '(' . join ( ', ' , $ strParams ) . ')' ; }
Gets the complete new statement as php code
30,884
private function GetParamString ( $ param ) { if ( $ param === null ) return "null" ; if ( is_string ( $ param ) ) return "'" . addcslashes ( $ param , "'" ) . "'" ; else if ( is_bool ( $ param ) ) return $ param ? "true" : "false" ; else if ( is_int ( $ param ) || is_float ( $ param ) ) return ( string ) $ param ; else if ( $ param instanceof WritableClass ) return $ param -> GetNewStatement ( ) ; else if ( is_array ( $ param ) ) { $ resultArr = array ( ) ; foreach ( $ param as $ key => $ val ) { $ resultArr [ ] = $ this -> GetParamString ( $ key ) . '=>' . $ this -> GetParamString ( $ val ) ; } return 'array(' . join ( ', ' , $ resultArr ) . ')' ; } else if ( $ param instanceof \ Phine \ Framework \ System \ Enum ) { $ value = $ param -> Value ( ) ; $ class = get_class ( $ param ) ; return "\\$class::ByValue('$value')" ; } throw new \ InvalidArgumentException ( 'A writable class must have primitive types, Enums, arrays and PhpWritable classes as construct params only.' ) ; }
Serializes the parameter as php code
30,885
protected function registerRoutes ( array $ routes ) { foreach ( $ routes as $ route => $ config ) { $ this -> registerRoute ( $ route , $ config ) ; } }
Registers a new route .
30,886
protected function getRouteByUrl ( $ url ) { $ url = str_replace ( $ this -> rootNode , '' , $ url ) ; $ nodes = explode ( self :: ROUTE_SEPARATOR , $ url ) ; $ routeTree = $ this -> routeTree ; $ ids = [ ] ; $ route = [ ] ; $ countNodes = count ( $ nodes ) ; $ uid = null ; for ( $ i = 0 ; $ i < $ countNodes ; ++ $ i ) { if ( is_array ( $ routeTree ) && isset ( $ routeTree [ $ nodes [ $ i ] ] ) ) { $ routeTree = $ routeTree [ $ nodes [ $ i ] ] ; } elseif ( preg_match ( '/{{(.*)}}/i' , key ( $ routeTree ) , $ variable ) > 0 ) { $ nodes [ $ i ] = '{{' . $ variable [ 1 ] . '}}' ; $ id = $ this -> extractId ( $ variable [ 1 ] ) ; if ( $ id !== null ) { $ uid = $ id ; } $ ids [ ] = $ nodes [ $ i ] ; $ routeTree = $ routeTree [ $ nodes [ $ i ] ] ; } else { throw new Doozr_Base_Presenter_Rest_Exception ( 'Route for URL "' . $ url . '" seems wrong. It could not be resolved.' , 400 ) ; } $ route [ ] = $ nodes [ $ i ] ; if ( $ i === ( $ countNodes - 1 ) ) { if ( is_object ( $ routeTree ) === true ) { $ routeTree -> id ( $ uid ) -> ids ( $ ids ) -> url ( $ url ) -> realRoute ( $ route ) -> rootNode ( $ this -> rootNode ) ; } else { throw new Doozr_Base_Presenter_Rest_Exception ( 'Route for URL "' . $ url . '" seems incomplete.' , 406 ) ; } } } return $ routeTree ; }
Returns the route matched by URL including configuration and extracted Ids ... We do only throws exceptions here instead of sending header directives like 404 405 406 . This is responsibility of the implementing application cause here too high level .
30,887
protected function isId ( $ input ) { $ result = false ; $ input = strtolower ( $ input ) ; if ( substr ( $ input , 0 , 2 ) === 'id' || substr ( $ input , - 2 , 2 ) === 'id' ) { $ result = true ; } return $ result ; }
Returns boolean status if input is Id field .
30,888
protected function run ( ) { $ this -> setRouteTree ( explodeTree ( $ this -> getRoutes ( ) , self :: ROUTE_SEPARATOR ) ) ; $ routeConfig = $ this -> getRouteByUrl ( $ this -> getStateObject ( ) -> getUrl ( ) ) ; $ headers = $ this -> getStateObject ( ) -> getHeaders ( ) ; if ( isset ( $ headers [ 'X_HTTP_METHOD_OVERRIDE' ] ) === true && $ routeConfig -> getOverride ( ) === true ) { $ requestMethod = $ headers [ 'X_HTTP_METHOD_OVERRIDE' ] ; $ this -> getStateObject ( ) -> setMethod ( $ requestMethod ) ; } else { $ requestMethod = $ this -> getStateObject ( ) -> getMethod ( ) ; } if ( $ routeConfig -> isAllowed ( $ requestMethod ) === false ) { throw new Doozr_Base_Presenter_Rest_Exception ( 'Method "' . $ this -> getStateObject ( ) -> getMethod ( ) . '" not allowed.' , 405 ) ; } if ( $ this -> validateInputArguments ( $ routeConfig -> getRequired ( ) , $ this -> getStateObject ( ) -> getQueryParams ( ) ) !== true ) { $ missingArguments = [ ] ; foreach ( $ routeConfig -> getRequired ( ) as $ key => $ value ) { if ( array_key_exists ( $ key , $ this -> getStateObject ( ) -> getQueryParams ( ) -> getArray ( ) ) === false ) { $ missingArguments [ ] = $ key . ( ( $ value !== null ) ? ' => ' . $ value : '' ) ; } } throw new Doozr_Base_Presenter_Rest_Exception ( 'Missing required argument' . ( ( count ( $ missingArguments ) > 1 ) ? 's' : '' ) . ': ' . implode ( ',' , $ missingArguments ) , 406 ) ; } $ data = $ this -> getModel ( ) -> getData ( $ this -> getStateObject ( ) , $ routeConfig ) ; $ this -> setData ( $ data ) ; }
Executes the configured subroutes if any matches .
30,889
protected function validateInputArguments ( array $ argumentsRequired , Doozr_Request_Arguments $ argumentsSent ) { $ valid = true ; $ requestBody = $ this -> getStateObject ( ) -> getRequestBody ( ) ; foreach ( $ argumentsRequired as $ requiredArgument => $ requiredValue ) { if ( ! isset ( $ argumentsSent -> { $ requiredArgument } ) && ( ! isset ( $ requestBody -> { $ requiredArgument } ) ) ) { $ valid = false ; } } return $ valid ; }
Checks if all required fields where passed with request .
30,890
public function install ( ) : OperationResult { $ result = new OperationResult ( ) ; $ sourcePath = "{$this->packageInstallDir}/.installer/%s/files" ; foreach ( $ this -> projectType -> getProjectDirs ( ) as $ projectDir ) { if ( is_dir ( sprintf ( $ sourcePath , $ projectDir ) ) ) { $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( sprintf ( $ sourcePath , $ projectDir ) , \ RecursiveDirectoryIterator :: SKIP_DOTS ) , \ RecursiveIteratorIterator :: SELF_FIRST ) ; foreach ( $ iterator as $ file ) { $ target = "{$this->projectRootDir}/{$iterator->getSubPathname()}" ; if ( $ file -> isDir ( ) ) { if ( ! is_dir ( $ target ) ) { if ( ! mkdir ( $ target ) ) { $ result -> addErrorMessage ( "<error>Could not create target directory '${target}'</error>" ) ; } } } elseif ( ! file_exists ( $ target ) ) { assert ( is_string ( $ file -> getRealPath ( ) ) ) ; if ( ! copy ( $ file -> getRealPath ( ) , $ target ) ) { $ result -> addErrorMessage ( "<error>Could not copy file to '${target}'</error>" ) ; } } } } } if ( ! $ result -> isFailure ( ) ) { $ result -> addStatusMessage ( "Successfully copied files from package {$this->packageName}" ) ; } return $ result ; }
Copies all files from package to target directory in project root - files that already exist are not copied
30,891
public function uninstall ( ) : OperationResult { $ result = new OperationResult ( ) ; $ sourcePath = "{$this->packageInstallDir}/.installer/%s/files" ; foreach ( $ this -> projectType -> getProjectDirs ( ) as $ projectDir ) { $ directory = sprintf ( $ sourcePath , $ projectDir ) ; if ( is_dir ( $ directory ) ) { $ iteratorPackage = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ directory , \ RecursiveDirectoryIterator :: SKIP_DOTS ) , \ RecursiveIteratorIterator :: CHILD_FIRST ) ; foreach ( $ iteratorPackage as $ file ) { $ target = "{$this->projectRootDir}/{$iteratorPackage->getSubPathname()}" ; if ( ! file_exists ( $ target ) ) { continue ; } if ( $ file -> isDir ( ) ) { @ rmdir ( $ target ) ; } else { assert ( is_string ( $ file -> getRealPath ( ) ) ) ; $ hashTarget = hash_file ( 'sha1' , $ target ) ; $ hashSource = hash_file ( 'sha1' , $ file -> getRealPath ( ) ) ; if ( $ hashSource === $ hashTarget ) { if ( ! @ unlink ( $ target ) ) { $ result -> addErrorMessage ( "<error>Could not delete file '${target}'</error>" ) ; } } } } } } if ( ! $ result -> isFailure ( ) ) { $ result -> addStatusMessage ( "Successfully uninstalled files for {$this->packageName}" ) ; } return $ result ; }
Tries to remove all files that were automatically installed . - removes empty directories - removes installed files if their content is identical to the fresh new file - uses sha1 for checksum
30,892
public function get ( $ path , $ default = null ) { $ array = $ this -> getValues ( ) ; if ( ! empty ( $ path ) ) { $ keys = $ this -> explode ( $ path ) ; foreach ( $ keys as $ key ) { if ( isset ( $ array [ $ key ] ) ) { $ array = $ array [ $ key ] ; } else { return $ default ; } } } return $ array ; }
Returns value by path .
30,893
public function set ( $ path , $ value ) { if ( ! empty ( $ path ) ) { $ at = & $ this -> getValues ( ) ; $ keys = $ this -> explode ( $ path ) ; while ( count ( $ keys ) > 0 ) { if ( count ( $ keys ) === 1 ) { if ( is_array ( $ at ) ) { $ at [ array_shift ( $ keys ) ] = $ value ; } else { throw new \ RuntimeException ( "Can not set value at this path ($path) because is not array." ) ; } } else { $ key = array_shift ( $ keys ) ; if ( ! isset ( $ at [ $ key ] ) ) { $ at [ $ key ] = [ ] ; } $ at = & $ at [ $ key ] ; } } } else { $ this -> values = $ value ; } }
Sets a value for path .
30,894
public function add ( $ path , array $ values ) { $ get = ( array ) $ this -> get ( $ path ) ; $ this -> set ( $ path , $ this -> arrayMergeRecursiveDistinct ( $ get , $ values ) ) ; }
Add a value to a path .
30,895
public function have ( $ path ) { $ keys = $ this -> explode ( $ path ) ; $ array = $ this -> values ; foreach ( $ keys as $ key ) { if ( isset ( $ array [ $ key ] ) ) { $ array = $ array [ $ key ] ; } else { return false ; } } return true ; }
Returns whether a path exists .
30,896
public function runRecipe ( ) : callable { return function ( array $ workPlan ) : ChefInterface { $ this -> workPlan = \ array_merge ( $ this -> workPlan , $ workPlan ) ; $ this -> cooking = true ; $ this -> updateStates ( ) ; $ this -> prepare ( ) ; $ this -> continue ( ) ; $ this -> clean ( ) ; return $ this ; } ; }
To execute a cooking and switch to cookine state .
30,897
public function getFailures ( bool $ skipEmptyValues = false ) : array { if ( $ this -> failures ) { if ( $ skipEmptyValues ) { $ net = [ ] ; foreach ( $ this -> failures as $ key => $ val ) { if ( $ val ) { $ net [ $ key ] = $ val ; } } return $ net ; } return $ this -> failures ; } return [ ] ; }
Get list of validation failures .
30,898
public function getFailureNames ( ) : array { if ( $ this -> failures ) { $ keys = array_keys ( $ this -> failures ) ; $ net = [ ] ; foreach ( $ keys as $ key ) { if ( $ key && ! ctype_digit ( '' . $ key ) ) { $ net [ ] = $ key ; } } return $ net ; } return [ ] ; }
Get keys of failures excluding keys that are numeric .
30,899
public function getAll ( QueryBuilder $ qb , array $ params = [ ] , array $ pageOpts = [ ] , $ inDeleted = false ) { if ( $ this -> softDelete && ! $ inDeleted ) { $ qb -> andWhere ( 't.' . $ this -> softDeleteName . ' IS NULL' ) ; } if ( ! empty ( $ pageOpts ) ) { $ rs = $ this -> paginate ( $ qb , $ pageOpts , $ params ) ; } else { $ rs = $ this -> db -> fetchAll ( $ qb -> getSQL ( ) , $ params ) ; } return $ rs ; }
Retorna todos os registros que casam com uma consulta montada num QueryBuilder .