idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
16,000
public function withPort ( $ port ) { $ url = clone $ this ; $ url -> port = $ port ; $ url -> hash = null ; return $ url ; }
Create a new instance with the specified port .
16,001
public function withQuery ( $ query ) { $ url = clone $ this ; $ url -> query = $ query ; $ url -> hash = null ; return $ url ; }
Create a new instance with the specified query string .
16,002
public static function registerApplicationPlugin ( ApplicationPlugin $ plugin , $ priority = self :: PRIORITY_NORMAL ) { if ( $ priority != self :: PRIORITY_HIGH && $ priority != self :: PRIORITY_NORMAL && $ priority != self :: PRIORITY_LOW ) { throw new ArchException ( 'Bad plugin priority' ) ; } $ pluginClass = get_class ( $ plugin ) ; if ( isset ( self :: $ plugins [ $ pluginClass ] ) ) { throw new ArchException ( 'Plugin ' . $ pluginClass . ' already registered' ) ; } self :: $ plugins [ $ pluginClass ] = $ plugin ; self :: $ pluginsOrder [ $ priority ] [ ] = $ pluginClass ; }
Register a MVC plugin
16,003
public static function getApplicationPlugin ( $ pluginClass ) { return isset ( self :: $ plugins [ $ pluginClass ] ) ? self :: $ plugins [ $ pluginClass ] : null ; }
Get a registered plugin by class name
16,004
public static function handleApplicationPlugins ( $ step ) { foreach ( self :: $ pluginsOrder as $ plugins ) { foreach ( $ plugins as $ pluginClass ) { self :: $ plugins [ $ pluginClass ] -> $ step ( ) ; } } }
Used in Application core please do not touch
16,005
public function findLimited ( $ limit = 0 ) { $ queryBuilder = $ this -> createQueryBuilder ( 'c' ) -> where ( 'c.enabled = :enabled' ) -> orderBy ( 'c.position' ) -> setParameters ( array ( 'enabled' => true , ) ) ; if ( $ limit != 0 ) { $ queryBuilder -> setMaxResults ( $ limit ) ; } return $ queryBuilder -> getQuery ( ) -> getResult ( ) ; }
Return a list of carousel items
16,006
public function codeString ( array $ task , $ full = true ) { return $ this -> _isCli || ( ! $ task [ 'code_string' ] ) ? $ task [ 'code_string' ] : $ this -> Html -> tag ( 'span' , $ this -> _text ( $ task [ 'code_string' ] , $ full ? 0 : Configure :: read ( 'Task.truncateCode' ) , true ) , array ( 'class' => 'label label-' . ( $ task [ 'code_string' ] == 'OK' ? 'success' : 'important' ) ) ) ; }
String return code
16,007
public function waiting ( array $ tasks , $ full = true ) { $ formattedTasks = $ this -> _formatWaiting ( $ tasks , true ) ; $ tasksCount = count ( $ formattedTasks ) ; if ( $ tasksCount === 0 ) { return $ this -> _none ( ) ; } if ( $ this -> _isCli ) { return implode ( ', ' , $ formattedTasks ) ; } elseif ( $ full ) { return implode ( ', ' , $ this -> _formatWaiting ( $ tasks , false ) ) ; } else { $ text = implode ( ', ' , $ this -> _formatWaiting ( array_slice ( $ tasks , 0 , Configure :: read ( 'Task.truncateWaitFor' ) ) , false ) ) ; $ text .= $ tasksCount > Configure :: read ( 'Task.truncateWaitFor' ) ? '...' : '' ; return $ this -> Html -> tag ( 'span' , $ text , array ( 'title' => implode ( ', ' , $ formattedTasks ) ) ) ; } }
Waiting for tasks
16,008
public function statistics ( array $ statistics ) { if ( $ this -> _isCli ) { return $ this -> _none ( 'Not allowed in cli' ) ; } if ( ! $ this -> settings [ 'chartEnabled' ] ) { return $ this -> _none ( 'Please install <b>imsamurai/cakephp-google-chart</b> plugin to view graph' ) ; } if ( empty ( $ statistics ) ) { return $ this -> _none ( ) ; } $ this -> GoogleChart -> load ( ) ; $ chartData = $ this -> GoogleChart -> dataFromArray ( array ( 'memory' => array_map ( 'floatval' , Hash :: extract ( $ statistics , '{n}.memory' ) ) , 'cpu' => array_map ( 'floatval' , Hash :: extract ( $ statistics , '{n}.cpu' ) ) , 'date' => array_map ( 'strtotime' , Hash :: extract ( $ statistics , '{n}.created' ) ) , 'statistics' => $ statistics ) , array ( 'date' => array ( 'v' => 'date.{n}' , 'f' => 'statistics.{n}.created' ) , 'memory' => 'memory.{n}' , 'cpu' => 'cpu.{n}' , '{"role": "annotation"}' => 'statistics.{n}.status' , ) ) ; return $ this -> GoogleChart -> draw ( 'LineChart' , $ chartData , array ( 'height' => 300 , 'width' => 800 , 'pointSize' => 5 , 'vAxis' => array ( 'title' => 'Percentage' ) , 'hAxis' => array ( 'title' => 'Time' ) , 'chartArea' => array ( 'left' => 50 , 'top' => 10 , 'height' => 230 , 'width' => 650 , ) ) ) ; }
Make statistics graph
16,009
protected function _formatWaiting ( array $ tasks , $ plain ) { $ dependsOnTaskFormatted = array ( ) ; foreach ( $ tasks as $ task ) { if ( ! in_array ( ( int ) $ task [ 'status' ] , array ( TaskType :: DEFFERED , TaskType :: RUNNING , TaskType :: STOPPING , TaskType :: UNSTARTED ) ) ) { continue ; } $ dependsOnTaskFormatted [ ] = $ plain ? $ task [ 'id' ] : $ this -> id ( $ task ) ; } return $ dependsOnTaskFormatted ; }
Waiting tasks formatter
16,010
protected function _dateDiff ( $ start = null , $ stop = null ) { if ( $ start ) { $ endDate = $ stop instanceof DateTime ? $ stop : new DateTime ( $ stop ? $ stop : 'now' ) ; $ startDate = $ start instanceof DateTime ? $ start : new DateTime ( $ start ) ; $ diff = $ startDate -> diff ( $ endDate ) -> format ( Configure :: read ( 'Task.dateDiffFormat' ) ) ; return $ this -> _isCli ? $ diff : $ this -> Html -> tag ( 'span' , $ diff ) ; } else { return $ this -> _none ( ) ; } }
Date diff formatter
16,011
public static function get ( $ uri , $ callback , $ params = [ ] ) { if ( is_string ( $ callback ) ) { $ callback = self :: str2closure ( $ callback ) ; } $ middlewares = array_merge ( self :: middlewaresByParams ( $ params ) , self :: middlewaresByParams ( self :: $ group_params ) ) ; self :: $ routes [ ] = new Route ( 'get' , $ uri , $ callback , $ middlewares ) ; }
set get route
16,012
private static function str2closure ( $ controllerAction ) { list ( $ controller , $ action ) = explode ( '@' , $ controllerAction ) ; return function ( $ request ) use ( $ controller , $ action ) { $ c = new $ controller ; return call_user_func ( [ $ c , $ action ] , $ request ) ; } ; }
convert string to closure
16,013
public function get ( $ key , $ default = null ) { if ( isset ( $ this -> data [ $ key ] ) ) { return $ this -> data [ $ key ] ; } return isset ( $ this -> session [ $ key ] ) ? $ this -> session [ $ key ] : $ default ; }
Retrive a value
16,014
public function load ( $ key , Clovers $ callback ) { if ( ! $ this -> has ( $ key ) ) { $ this -> set ( $ key , $ callback ( $ key ) ) ; } return $ this -> get ( $ key ) ; }
Retrive the value associated with the specified key or associate the specified key with the value returned by invoking the callback .
16,015
public function handle ( $ framework_file , ImageConfiguration $ config , array $ optional_data = [ ] ) { $ image_file = $ this -> prepareImageFile ( $ framework_file ) ; $ response = $ this -> validator -> validate ( $ image_file , $ config -> rules ) ; if ( $ response -> success ( ) ) { if ( $ record = $ this -> image_repo -> findExistingImageable ( $ config -> optional_data ) ) { $ this -> image_repo -> delete ( $ record ) ; } $ record = $ this -> image_repo -> create ( [ 'name' => $ config -> image_name , 'disk' => $ config -> temp_disk , 'filename' => $ image_file -> filename , 'path' => $ config -> directory , 'status' => 'pending' , 'width' => $ image_file -> width , 'height' => $ image_file -> height , 'mime_type' => $ image_file -> mime_type , 'extension' => $ image_file -> extension , 'size' => $ image_file -> size , 'alt' => $ optional_data [ 'alt' ] ?? null , 'title' => $ optional_data [ 'title' ] ?? null , 'description' => $ optional_data [ 'description' ] ?? null , ] ) ; $ this -> storage -> put ( $ image_file -> stream , $ record -> disk , "$record->path/$record->uuid" , $ record -> filename ) ; $ response = new StandardServiceResponse ( true , [ 'image' => $ record , ] , 'File successfully uploaded' ) ; } return $ response ; }
Handle Image Upload
16,016
protected function createChild ( $ key ) { $ relation = $ this -> getValueOrRelationForKey ( $ key ) ; if ( ! $ relation instanceof Relation ) { return $ relation ; } $ this -> supportedRelationOrThrow ( $ key , $ relation ) ; $ model = Rel :: make ( $ relation ) -> getChild ( ) ; if ( ! $ this -> isEloquentObject ( $ model ) ) { throw new \ LogicException ( sprintf ( 'newModelFromRelation should return an Eloquent Model/Collection, but returned a %s (parent: %s, key: %s, relation: %s)' , get_type_class ( $ model ) , get_type_class ( $ this -> getDelegatedStorage ( ) ) , $ key , get_type_class ( $ relation ) ) ) ; } return $ model ; }
Caches a relation for later use . Creates a new model in case of empty values .
16,017
public function clans ( $ param , $ members = false ) { if ( is_array ( $ param ) ) { return $ this -> _clansByFilter ( $ param ) ; } else if ( $ members ) { return $ this -> _clansMembersOnly ( $ param ) ; } return $ this -> _clanById ( $ param ) ; }
Search for clans by different approaches .
16,018
private function _clansMembersOnly ( string $ param ) : array { $ curlClient = curl_init ( self :: BASE_URL . self :: CLANS_URL . '/' . \ urlencode ( $ param ) . '/members' ) ; curl_setopt ( $ curlClient , CURLOPT_HTTPHEADER , $ this -> _curlHeader ) ; curl_setopt ( $ curlClient , CURLOPT_RETURNTRANSFER , true ) ; $ results = json_decode ( curl_exec ( $ curlClient ) , true ) ; $ members = [ ] ; foreach ( $ results [ 'items' ] as $ result ) { $ members [ ] = Player :: create ( $ result ) ; } return $ members ; }
Search for clan members only of a specific clan
16,019
private function _clanById ( string $ param ) : Clan { $ curlClient = curl_init ( self :: BASE_URL . self :: CLANS_URL . '/' . \ urlencode ( $ param ) ) ; curl_setopt ( $ curlClient , CURLOPT_HTTPHEADER , $ this -> _curlHeader ) ; curl_setopt ( $ curlClient , CURLOPT_RETURNTRANSFER , true ) ; $ result = json_decode ( curl_exec ( $ curlClient ) , true ) ; return Clan :: create ( $ result ) ; }
Retrieves the clan who matches the given id
16,020
private function _clansByFilter ( array $ params ) : array { $ url = self :: BASE_URL . self :: CLANS_URL . '?' ; $ url .= http_build_query ( $ params ) ; $ curlClient = curl_init ( $ url ) ; curl_setopt ( $ curlClient , CURLOPT_HTTPHEADER , $ this -> _curlHeader ) ; curl_setopt ( $ curlClient , CURLOPT_RETURNTRANSFER , true ) ; $ results = json_decode ( curl_exec ( $ curlClient ) , true ) ; $ clans = [ ] ; foreach ( $ results [ 'items' ] as $ result ) { $ clans [ ] = Clan :: create ( $ result ) ; } return $ clans ; }
Retrieves a list of clans who matches a set of filters
16,021
private function _locationsById ( int $ id ) : Location { $ curlClient = curl_init ( self :: BASE_URL . self :: LOCATIONS_URL . '/' . $ id ) ; curl_setopt ( $ curlClient , CURLOPT_HTTPHEADER , $ this -> _curlHeader ) ; curl_setopt ( $ curlClient , CURLOPT_RETURNTRANSFER , true ) ; $ result = json_decode ( curl_exec ( $ curlClient ) , true ) ; return Location :: create ( $ result ) ; }
Returns a location with the given id
16,022
private function _locationsByIdAndRank ( int $ id , $ rank ) { $ curlClient = curl_init ( self :: BASE_URL . self :: LOCATIONS_URL . '/' . $ id . '/rankings/' . $ rank ) ; curl_setopt ( $ curlClient , CURLOPT_HTTPHEADER , $ this -> _curlHeader ) ; curl_setopt ( $ curlClient , CURLOPT_RETURNTRANSFER , true ) ; $ results = json_decode ( curl_exec ( $ curlClient ) , true ) ; $ items = [ ] ; foreach ( $ results [ 'items' ] as $ result ) { if ( $ rank === RankingId :: CLANS ) { $ items [ ] = Clan :: create ( $ result ) ; } else { $ items [ ] = Player :: create ( $ result ) ; } } return $ items ; }
Based on a Location retrieve the local rankings
16,023
public function load ( $ resource , $ type = null ) { $ path = $ this -> locator -> locate ( $ resource ) ; if ( ! stream_is_local ( $ path ) ) { throw new \ InvalidArgumentException ( sprintf ( 'This is not a local file "%s".' , $ path ) ) ; } if ( ! file_exists ( $ path ) ) { throw new \ InvalidArgumentException ( sprintf ( 'File "%s" not found.' , $ path ) ) ; } $ this -> loaded [ $ resource ] = $ path ; return Yaml :: parse ( file_get_contents ( $ path ) ) ; }
Loads and parses the given Yaml file into a PHP array .
16,024
public function getResponse ( ) { $ response = redirect ( ) -> to ( $ this -> getRedirectUrl ( ) ) ; $ response -> withInput ( $ this -> request -> input ( ) ) ; $ response -> withErrors ( $ this -> getErrors ( ) , 'default' ) ; $ response -> setCharset ( config ( 'app.charset' , 'UTF-8' ) ) ; return $ response ; }
Get the underlying response instance .
16,025
protected function getErrors ( ) { $ arr = [ 'error' => $ this -> getMessage ( ) ] ; if ( count ( $ this -> attrs ) > 0 ) { $ arr [ 'attrs' ] = $ this -> getAttrs ( ) ; } if ( count ( $ this -> attrsCustom ) > 0 ) { $ arr [ 'attrscustom' ] = $ this -> getAttrsCustom ( ) ; } return $ arr ; }
Array de erros .
16,026
public function GetSolutionDirectoryList ( \ Puzzlout \ Framework \ Core \ Application $ app ) { $ Cacher = \ Puzzlout \ Framework \ Core \ Cache \ BaseCache :: Init ( $ app -> config ) ; if ( ! $ Cacher -> KeyExists ( CacheKeys :: SOLUTION_FOLDERS ) ) { $ SolutionPathListArray = ArrayFilterDirectorySearch :: Init ( $ app ) -> RecursiveScanOf ( "APP_ROOT_DIR" , \ Puzzlout \ Framework \ Core \ DirectoryManager \ Algorithms \ ArrayListAlgorithm :: ExcludeList ( ) ) ; $ Cacher -> Create ( CacheKeys :: SOLUTION_FOLDERS , $ SolutionPathListArray ) ; } else { $ SolutionPathListArray = $ Cacher -> Read ( CacheKeys :: SOLUTION_FOLDERS , array ( ) ) ; } return $ SolutionPathListArray ; }
Retrieves the solution directory list . It caches the result if not already done so that it retrieves it faster the next occurrences .
16,027
public function IsFolderMatchingFilter ( $ path , $ regexFilter ) { return \ Puzzlout \ Framework \ Helpers \ RegexHelper :: Init ( $ path ) -> IsMatch ( $ regexFilter ) ; }
Test to the path against the filter .
16,028
public function AddFolderPathToListItems ( $ key , $ path ) { array_push ( $ this -> ListItemArray , \ Puzzlout \ Framework \ BO \ ListItem :: Init ( $ key , $ path ) ) ; }
Add a ListItem object to the field ListItemArray .
16,029
protected function fixCommandDefinition ( BaseCommand $ command ) { $ definition = $ command -> getDefinition ( ) ; if ( ! $ definition -> hasOption ( 'verbose' ) ) { $ definition -> addOption ( new InputOption ( 'verbose' , 'v|vv|vvv' , InputOption :: VALUE_NONE , 'Shows more details including new commits pulled in when updating packages.' ) ) ; } if ( ! $ definition -> hasOption ( 'profile' ) ) { $ definition -> addOption ( new InputOption ( 'profile' , null , InputOption :: VALUE_NONE , 'Display timing and memory usage information' ) ) ; } if ( ! $ definition -> hasOption ( 'no-plugins' ) ) { $ definition -> addOption ( new InputOption ( 'no-plugins' , null , InputOption :: VALUE_NONE , 'Whether to disable plugins.' ) ) ; } if ( ! $ definition -> hasOption ( 'working-dir' ) ) { $ definition -> addOption ( new InputOption ( 'working-dir' , '-d' , InputOption :: VALUE_REQUIRED , 'If specified, use the given directory as working directory.' ) ) ; } }
Add missing definition options to the command usually defined by the application .
16,030
protected function attachComposerFactory ( BaseCommand $ command ) { if ( ! method_exists ( $ command , 'setComposerFactory' ) ) { throw new \ InvalidArgumentException ( 'The passed command does not implement method setComposerFactory()' ) ; } $ command -> setComposerFactory ( function ( ) { return Factory :: create ( $ this -> getIO ( ) ) ; } ) ; return $ command ; }
Attach the composer factory to the command .
16,031
protected function executeCommand ( BaseCommand $ command , InputInterface $ input , OutputInterface $ output ) { try { if ( 0 !== ( $ statusCode = $ command -> run ( $ input , $ output ) ) ) { throw new \ RuntimeException ( 'Error: command exit code was ' . $ statusCode ) ; } } catch ( \ Exception $ exception ) { throw new \ RuntimeException ( $ exception -> getMessage ( ) , $ exception -> getCode ( ) , $ exception ) ; } }
Execute the command and throw exceptions on errors .
16,032
public function register ( string $ eventCode , callable $ listener ) { $ this -> assertValidEventCode ( $ eventCode ) ; if ( false === isset ( $ this -> eventListeners [ $ eventCode ] ) ) { $ this -> eventListeners [ $ eventCode ] = [ ] ; } $ this -> eventListeners [ $ eventCode ] [ ] = $ listener ; return $ this ; }
Register a listener for the given event code
16,033
public function dispatch ( string $ eventCode , EventInterface $ event ) { $ this -> assertValidEventCode ( $ eventCode ) ; if ( true === isset ( $ this -> eventListeners [ $ eventCode ] ) ) { foreach ( $ this -> eventListeners [ $ eventCode ] as $ listener ) { $ listener ( $ event ) ; } } return $ this ; }
Invoke all event listeners for the given event code
16,034
public function setStrictVariables ( bool $ isEnabled = true ) : self { if ( $ isEnabled ) { $ this -> twigEnvironment -> enableStrictVariables ( ) ; } else { $ this -> twigEnvironment -> disableStrictVariables ( ) ; } return $ this ; }
Sets whether strict variables should be enabled .
16,035
public function remove ( $ key ) { if ( ! is_string ( $ key ) && ! is_numeric ( $ key ) ) { throw new InvalidArgumentException ( 'Invalid key name given! Key config to remove must be as a string!' ) ; } if ( ! $ this -> exist ( $ key ) ) { return ; } if ( ( $ count = preg_match_all ( '/(?:^[^\[]+)|\[[^]]*\]/' , $ key , $ matches ) ) > 1 ) { $ firstKey = reset ( $ matches [ 0 ] ) ; $ keyName = $ firstKey ; $ tmp = $ this -> collection [ $ keyName ] ; if ( ! is_array ( $ tmp ) ) { return ; } array_shift ( $ matches [ 0 ] ) ; $ unsetPosition = 0 ; foreach ( $ matches [ 0 ] as $ keyNum => $ keyName ) { $ keyName = trim ( $ keyName , '[]' ) ; if ( $ unsetPosition <> $ keyNum && ( ! is_array ( $ tmp ) || ! array_key_exists ( $ keyName , $ tmp ) ) ) { return ; } $ unsetPosition ++ ; $ tmp = $ tmp [ $ keyName ] ; } $ tmp = $ this -> collection [ $ firstKey ] ; $ currentUnsetPosition = 0 ; $ recursiveUnset = function ( & $ array , $ unwanted_key ) use ( $ unsetPosition , & $ currentUnsetPosition , & $ recursiveUnset ) { $ currentUnsetPosition ++ ; if ( $ unsetPosition !== $ currentUnsetPosition ) { if ( array_key_exists ( $ unwanted_key , $ array ) ) { unset ( $ array [ $ unwanted_key ] ) ; } return ; } foreach ( $ array as & $ value ) { if ( is_array ( $ value ) ) { $ recursiveUnset ( $ value , $ unwanted_key ) ; } } } ; $ recursiveUnset ( $ tmp , $ keyName ) ; $ this -> collection [ $ firstKey ] = $ tmp ; unset ( $ tmp ) ; return ; } unset ( $ this -> collection [ $ key ] ) ; }
Remove Key from nested selector
16,036
public function ready ( ) { if ( $ this -> ready ) { return $ this ; } $ this -> raw = @ file_get_contents ( $ this -> pathname ) ; if ( ! $ this -> raw ) { throw new AccessFileException ( $ this -> pathname , "Cannot ready resource '{$this->name}'" ) ; } try { $ data = Json :: parse ( $ this -> raw , true ) ; if ( ! is_array ( $ data ) ) { throw new \ InvalidArgumentException ( "Resource data is not array" ) ; } } catch ( \ InvalidArgumentException $ e ) { throw new ReadFileException ( $ this -> pathname , "Cannot read resource '{$this->name}', json parser error: " . $ e -> getCode ( ) ) ; } if ( isset ( $ data [ 'type' ] ) && is_string ( $ data [ 'type' ] ) ) { $ this -> type = $ data [ 'type' ] ; } $ this -> ready = true ; $ this -> items = $ data ; return $ this ; }
Load resource content data
16,037
public function hasType ( string $ type ) : bool { if ( substr ( $ type , 0 , 2 ) !== "#/" ) { $ type = "#/{$type}" ; } return $ this -> getType ( ) === $ type ; }
Compare resource type
16,038
public function sync ( ) { $ actionMap = $ this -> Guardian -> getActionMap ( ) ; $ groups = $ this -> GroupPermissions -> Groups -> find ( 'all' ) -> where ( [ 'Groups.id <>' => 1 ] ) ; $ connection = $ this -> GroupPermissions -> connection ( ) ; $ connection -> begin ( ) ; $ this -> GroupPermissions -> deleteAll ( [ 'path IN' => $ this -> Guardian -> getGuestActions ( ) ] ) ; foreach ( $ groups as $ group ) { try { $ this -> GroupPermissions -> createMissingPermissions ( $ group -> id , $ actionMap ) ; $ this -> GroupPermissions -> deleteOrphans ( $ group -> id , $ actionMap ) ; } catch ( Exception $ e ) { $ connection -> rollback ( ) ; } } if ( $ connection -> inTransaction ( ) ) { $ connection -> commit ( ) ; } $ this -> eventManager ( ) -> dispatch ( new Event ( 'Guardian.GroupPermissions.afterSync' ) ) ; $ this -> Flash -> success ( __d ( 'wasabi_core' , 'All permissions have been synchronized.' ) ) ; $ this -> redirect ( [ 'action' => 'index' ] ) ; return ; }
Sync action GET
16,039
public function update ( ) { if ( ! $ this -> request -> is ( 'post' ) ) { if ( $ this -> request -> is ( 'ajax' ) ) { throw new MethodNotAllowedException ( ) ; } else { $ this -> Flash -> error ( $ this -> invalidRequestMessage ) ; $ this -> redirect ( [ 'action' => 'index' ] ) ; return ; } } if ( empty ( $ this -> request -> data ) && ! $ this -> request -> is ( 'ajax' ) ) { $ this -> Flash -> warning ( __d ( 'wasabi_core' , 'There are no permissions to update yet.' ) ) ; $ this -> redirect ( [ 'action' => 'index' ] ) ; return ; } $ permissions = $ this -> GroupPermissions -> patchEntities ( $ this -> GroupPermissions -> find ( 'all' ) , $ this -> request -> data ) ; $ connection = $ this -> GroupPermissions -> connection ( ) ; $ connection -> begin ( ) ; foreach ( $ permissions as $ permission ) { if ( ! $ this -> GroupPermissions -> save ( $ permission ) ) { $ connection -> rollback ( ) ; break ; } } if ( $ connection -> inTransaction ( ) ) { $ connection -> commit ( ) ; Cache :: clear ( false , 'wasabi/core/group_permissions' ) ; if ( $ this -> request -> is ( 'ajax' ) ) { $ status = 'success' ; $ this -> set ( compact ( 'status' ) ) ; $ this -> set ( '_serialize' , [ 'status' ] ) ; } else { $ this -> Flash -> success ( __d ( 'wasabi_core' , 'All permissions have been saved.' ) ) ; $ this -> redirect ( [ 'action' => 'index' ] ) ; return ; } } else { $ this -> Flash -> error ( $ this -> dbErrorMessage ) ; } }
Update action POST | AJAX
16,040
public static function run ( ) { $ run_migration = \ Cli :: option ( 'migrate' , \ Cli :: option ( 'm' , false ) ) ; $ run_validation = $ run_migration ? true : \ Cli :: option ( 'validate' , \ Cli :: option ( 'v' , false ) ) ; if ( ! $ run_migration and ! $ run_validation ) { return static :: help ( ) ; } $ validated = true ; if ( $ run_validation ) { $ validated = static :: run_validation ( ) ; } if ( $ run_migration ) { if ( $ validated ) { $ migrated = static :: run_migration ( ) ; if ( $ migrated ) { \ Cli :: write ( 'Migration succesfully finished' , 'light_green' ) ; } else { \ Cli :: write ( "\n" . 'Migration failed. Skipping the remainder of the migration. Please correct the errors and run again.' , 'light_red' ) ; } } else { \ Cli :: write ( "\n" . 'Validation failed. Skipping the actual migration. Please correct the errors.' , 'light_red' ) ; } } }
Show help .
16,041
public function type ( $ mapping_type ) { $ args = func_get_args ( ) ; $ mapping_type = array_shift ( $ args ) ; if ( empty ( $ args ) ) return $ this -> merge ( [ 'map.type' => $ mapping_type ] ) ; return $ this -> merge ( [ 'map.type' => $ mapping_type , 'map.params' => $ args ] ) ; }
Sets result mapping options
16,042
public function resultMap ( $ result_map ) { if ( ! is_string ( $ result_map ) ) { if ( is_object ( $ result_map ) ) $ result_map = get_class ( $ result_map ) ; else throw new \ InvalidArgumentException ( "Method 'resultMap' expects a string or valid a result map instance." ) ; } return $ this -> merge ( [ 'map.result' => $ result_map ] ) ; }
Sets the result map class to apply to obtained result
16,043
public function cache ( $ cache_key , $ cache_ttl = 0 ) { if ( ! is_string ( $ cache_key ) || empty ( $ cache_key ) ) throw new \ InvalidArgumentException ( "Cache key is not a valid string." ) ; if ( ! is_integer ( $ cache_ttl ) || $ cache_ttl < 0 ) throw new \ InvalidArgumentException ( "Cache TTL is not a valid integer." ) ; return $ this -> merge ( [ 'cache.key' => $ cache_key , 'cache.ttl' => $ cache_ttl ] ) ; }
Sets cache key and ttl
16,044
public static function get_by_name_short ( $ name ) { $ db = Database :: Get ( ) ; $ id = $ db -> get_one ( 'SELECT id FROM language WHERE name_short=?' , [ $ name ] ) ; if ( $ id === null ) { throw new \ Exception ( 'No such language' ) ; } $ language = self :: get_by_id ( $ id ) ; return $ language ; }
Get by name_short
16,045
protected function registerClassMap ( array $ classMap ) { foreach ( $ classMap as $ file ) { $ arrClasses = require $ file ; if ( ! ArrayUtils :: isHashTable ( $ arrClasses , true ) ) { throw new Exception \ RuntimeException ( 'Config autoload for classmap is invalid' ) ; } if ( ! empty ( $ arrClasses ) ) { $ this -> loader -> registerClasses ( $ arrClasses ) ; } } }
Register class map
16,046
public function register ( ) { $ moduleHandler = $ this -> diFactory -> get ( 'moduleHandler' ) ; $ autoloadConf = $ moduleHandler -> getModulesAutoloadConfig ( ) ; if ( isset ( $ autoloadConf [ 'namespaces' ] ) ) { if ( ! ArrayUtils :: isHashTable ( $ autoloadConf [ 'namespaces' ] ) ) { throw new Exception \ RuntimeException ( 'Config autoload for namespace is invalid' ) ; } $ this -> loader -> registerNamespaces ( $ autoloadConf [ 'namespaces' ] ) ; } if ( isset ( $ autoloadConf [ 'classmap' ] ) ) { $ this -> registerClassMap ( $ autoloadConf [ 'classmap' ] ) ; } $ this -> loader -> register ( ) ; return $ this ; }
Auto register namespace and class map
16,047
public function header ( $ header = null ) { if ( $ this -> _status != null ) { array_push ( $ this -> _headers , $ header ) ; return true ; } else { return $ this -> _headers ; } }
add header to the stack get headers
16,048
public function status ( $ status = null ) { if ( $ status != null ) { if ( array_key_exists ( $ status , $ this -> _statusCode ) ) { $ this -> _status = $ status ; } return true ; } else { return $ this -> _status ; } }
set the status code . If you use 404 403 or 500 the framework will display an error page get the status code
16,049
public function contentType ( $ contentType = null ) { if ( $ contentType != null ) { $ this -> _contentType = $ contentType ; return true ; } else { return $ this -> _contentType ; } }
set Content - Type without Content - Type get Content - Type
16,050
public function run ( ) { header ( 'Content-Type: ' . $ this -> _contentType ) ; if ( $ this -> _status != 200 ) { http_response_code ( $ this -> _status ) ; } if ( array_key_exists ( $ this -> _status , $ this -> _statusErrorPage ) ) { $ tpl = new Template ( $ this -> _statusErrorPage [ $ this -> _status ] , $ this -> _status , '0' , Request :: instance ( ) -> lang ) ; $ tpl -> assign ( [ 'code' => $ this -> _status , 'description' => $ this -> _statusCode [ $ this -> _status ] ] ) ; $ this -> _page = $ tpl -> show ( ) ; } else { foreach ( $ this -> _headers as $ value ) { header ( $ value ) ; } } }
execute all the headers
16,051
public function page ( $ page = null ) { if ( $ page != null ) { $ this -> _page = $ page ; return true ; } else { return $ this -> _page ; } }
return the page content
16,052
private function register ( EntityFactoryInterface $ factory ) : self { $ this -> mapping = $ this -> mapping -> put ( get_class ( $ factory ) , $ factory ) ; return $ this ; }
Register the given entity factory instance
16,053
public static function checkComposerVersion ( Event $ event ) { $ composer = $ event -> getComposer ( ) ; $ io = $ event -> getIO ( ) ; $ version = $ composer :: VERSION ; if ( $ version === '@package_version@' ) { $ io -> writeError ( '<warning>You are running a development version of Composer. If you experience problems, please update Composer to the latest stable version.</warning>' ) ; } elseif ( Comparator :: lessThan ( $ version , '1.0.0' ) ) { $ io -> writeError ( '<error>UpMembership requires Composer version 1.0.0 or higher. Please update your Composer before continuing</error>.' ) ; exit ( 1 ) ; } }
Checks if the installed version of Composer is compatible .
16,054
public function toPrivateArray ( ) { return array ( 'number' => $ this -> getNumber ( ) , 'holder_name' => $ this -> getHolderName ( ) , 'expiration_year' => $ this -> getExpirationYear ( ) , 'expiration_month' => $ this -> getExpirationMonth ( ) , 'security_code' => $ this -> getSecurityCode ( ) , ) ; }
Returns only private properties that must be encrypted before sending
16,055
public function set ( $ key , $ value ) { if ( ! $ value instanceof EmitterInterface ) { throw new InvalidArgumentException ( "Only EmitterInterface object can be putted in a " . "EmittersMap." ) ; } return parent :: set ( $ key , $ value ) ; }
Puts a new emitter in the map .
16,056
public function loadConfig ( $ file ) { if ( file_exists ( $ file ) ) { $ config = include $ file ; $ driver = $ config [ 'driver' ] ; if ( $ driver == 'file' ) { $ session = new \ Wudimei \ Session \ File ( $ config ) ; } $ this -> session = $ session ; } else { throw new \ Exception ( 'sesstion config file "' . $ file . '" does not exists' ) ; } }
load config array from file
16,057
private function getFactoryForType ( $ taskType ) { foreach ( $ this -> factories as $ factory ) { if ( $ factory -> isTypeSupported ( $ taskType ) ) { return $ factory ; } } return null ; }
Search the factory that can handle the type .
16,058
public function retrieveByID ( $ identifier ) { $ user = $ this -> conn -> { $ this -> table } -> findOne ( array ( '_id' => new \ MongoId ( $ identifier ) ) ) ; if ( ! is_null ( $ user ) ) { return new MongolUser ( ( array ) $ user ) ; } }
Retrieve a user by their unique idenetifier .
16,059
protected function model ( $ class = false ) { if ( $ class !== false ) { return app ( $ class ) ; } if ( ! is_null ( $ this -> model ) ) { return $ this -> model ; } return $ this -> model = app ( $ this -> modelName ) ; }
Create model .
16,060
public function fetch ( $ url ) { $ SHDObject = $ this -> getSHDWrapper ( $ url ) ; $ urls = $ this -> getPageUrls ( $ SHDObject ) ; $ titles = $ this -> getPageTitles ( $ SHDObject ) ; $ snippets = $ this -> getPageSnippets ( $ SHDObject ) ; return array ( 'urls' => $ urls , 'titles' => $ titles , 'snippets' => $ snippets ) ; }
Get a multidimensional array with urls titles and snippets for a given SERP url .
16,061
public function cacheHit ( $ url ) { $ file = FileSystemHelper :: getCachedEntry ( $ url , $ this -> getCacheDir ( ) ) ; return $ this -> isCaching ( ) && FileSystemHelper :: cacheEntryExists ( $ file ) && FileSystemHelper :: validateCache ( $ file , $ this -> getCacheTTL ( ) , $ this -> isCachingForever ( ) ) ; }
Check if cache should be hit for a given url request .
16,062
public function setCacheDir ( $ dir ) { if ( GenericValidator :: validateDirName ( $ dir ) ) { $ this -> cacheDir = $ dir ; FileSystemHelper :: setUpDir ( $ dir ) ; return true ; } return false ; }
Set the path to the cache folder .
16,063
public function setCacheTTL ( $ hours ) { if ( GenericValidator :: validateExpirationTime ( $ hours ) ) { $ this -> cacheTTL = $ hours ; return true ; } return false ; }
Set the cache duration expressed in hours .
16,064
public function enableCaching ( ) { if ( FileSystemHelper :: folderExists ( $ this -> getCacheDir ( ) ) ) { $ this -> caching = true ; return true ; } return false ; }
Turn caching on . Prevent turning caching on if the cache folder hasn t been yet created .
16,065
public function setCharset ( $ charset ) { if ( GenericValidator :: validateCharset ( $ charset ) ) { $ this -> charset = $ charset ; return true ; } return false ; }
Set the charset used by the SimpleHtmlDom object .
16,066
protected function cleanText ( $ text ) { $ strippedText = strip_tags ( $ text ) ; $ strippedText = htmlentities ( $ strippedText , ENT_QUOTES , $ this -> getCharset ( ) , FALSE ) ; return html_entity_decode ( $ strippedText , ENT_QUOTES , $ this -> getCharset ( ) ) ; }
Extract textual data from fetched raw html text .
16,067
protected function normalizeResult ( $ resultArray ) { $ countArr = count ( $ resultArray ) ; if ( $ countArr > 10 ) { $ resultArray = array_slice ( $ resultArray , 0 , 10 ) ; } else if ( $ countArr < 10 ) { for ( $ i = $ countArr ; $ i < self :: DEFAULT_RESULT_NUMBER ; $ i ++ ) $ resultArray [ $ i ] = self :: DEFAULT_PAD_ENTRY ; } return $ resultArray ; }
Normalize result array by slicing it or by adding padding .
16,068
public function protectedLink ( $ title , $ url , $ options = [ ] , $ displayLinkTextIfUnauthorized = false ) { $ url = $ this -> _getUrl ( $ url ) ; if ( ! guardian ( ) -> hasAccess ( $ url ) ) { if ( $ displayLinkTextIfUnauthorized ) { return $ title ; } return '' ; } return $ this -> link ( $ title , $ url , $ options ) ; }
Create a properly prefixed backend link .
16,069
public function unprotectedLink ( $ title , $ url , $ options = [ ] ) { $ url = $ this -> _getUrl ( $ url ) ; return $ this -> link ( $ title , $ url , $ options ) ; }
Create a properly prefixed backend link and don t check permissions .
16,070
public function protectedConfirmationLink ( $ title , $ url , $ options , $ displayLinkTextIfUnauthorized = false ) { if ( ! isset ( $ options [ 'confirm-message' ] ) ) { user_error ( '\'confirm-message\' option is not set on protectedConfirmationLink.' ) ; $ options [ 'confirm-message' ] = '' ; } if ( ! isset ( $ options [ 'confirm-title' ] ) ) { user_error ( '\'confirm-title\' option is not set on protectedConfirmationLink.' ) ; $ options [ 'confirm-title' ] = '' ; } $ url = $ this -> _getUrl ( $ url ) ; if ( ! guardian ( ) -> hasAccess ( $ url ) ) { if ( $ displayLinkTextIfUnauthorized ) { return $ title ; } return '' ; } $ linkOptions = [ 'data-modal-header' => $ options [ 'confirm-title' ] , 'data-modal-body' => '<p>' . $ options [ 'confirm-message' ] . '</p>' , 'data-method' => 'post' , 'data-toggle' => 'confirm' ] ; unset ( $ options [ 'confirm-title' ] , $ options [ 'confirm-message' ] ) ; if ( isset ( $ options [ 'ajax' ] ) && $ options [ 'ajax' ] === true ) { $ linkOptions [ 'data-modal-ajax' ] = 1 ; unset ( $ options [ 'ajax' ] ) ; if ( isset ( $ options [ 'notify' ] ) ) { $ linkOptions [ 'data-modal-notify' ] = $ options [ 'notify' ] ; unset ( $ options [ 'notify' ] ) ; } if ( isset ( $ options [ 'event' ] ) ) { $ linkOptions [ 'data-modal-event' ] = $ options [ 'event' ] ; unset ( $ options [ 'event' ] ) ; } } if ( isset ( $ options [ 'void' ] ) && $ options [ 'void' ] === true ) { $ linkOptions [ 'data-modal-action' ] = Router :: url ( $ url ) ; $ url = 'javascript:void(0)' ; } $ linkOptions = Hash :: merge ( $ linkOptions , $ options ) ; return $ this -> link ( $ title , $ url , $ linkOptions ) ; }
Create a backend confirmation link .
16,071
public static function convert ( string $ input , int $ to ) : string { $ string = self :: normalize ( $ input ) ; $ parts = explode ( ' ' , $ string ) ; array_walk ( $ parts , function ( & $ part ) { $ part = ucfirst ( $ part ) ; } ) ; switch ( $ to ) { case self :: TYPE_NAMESPACE : return implode ( '\\' , $ parts ) ; case self :: TYPE_TABLE : return strtolower ( implode ( '_' , $ parts ) ) ; case self :: TYPE_VARIABLE : case self :: TYPE_ANGULAR_COMPONENT : return lcfirst ( implode ( '' , $ parts ) ) ; case self :: TYPE_PATH : return implode ( '/' , $ parts ) ; case self :: TYPE_URL : return strtolower ( implode ( '/' , $ parts ) ) ; case self :: TYPE_CSS_IDENTIFIER : case self :: TYPE_ANGULAR_TAG : return strtolower ( implode ( '-' , $ parts ) ) ; case self :: TYPE_ANGULAR_MODULE : return strtolower ( implode ( '.' , $ parts ) ) ; default : throw new DomainException ( "Please use one of the `TYPE_` constants on the `Codger\Generate\Language` class as 2nd parameter." ) ; } }
Convert input string to a different format .
16,072
public function setTemplate ( $ name , $ path ) { if ( ! isset ( $ this -> templates [ $ name ] ) ) { throw new UnexpectedValueException ( sprintf ( 'Unexpected template name "%s" provided.' , is_string ( $ name ) ? $ name : gettype ( $ name ) ) ) ; } $ finfo = new SplFileInfo ( $ path ) ; $ realPath = $ finfo -> getRealPath ( ) ; if ( ! $ realPath ) { throw new InvalidArgumentException ( sprintf ( 'Invalid path "%s" of template "%s" provided.' , $ path , $ name ) ) ; } $ extension = $ finfo -> getExtension ( ) ; if ( 'phtml' !== $ extension ) { throw new InvalidArgumentException ( sprintf ( 'Invalid file extension "%s" of template "%s"; the extension ' . 'of template file must be "phtml".' , $ extension , $ name ) ) ; } $ this -> templates [ $ name ] = $ realPath ; }
Sets template .
16,073
public function get ( $ abstract , $ args = [ ] ) { if ( $ this -> has ( $ abstract ) ) { return $ this -> retrieve ( $ this -> container , $ abstract , $ args ) ; } throw new Exceptions \ NotFoundException ( "Abstract '{$abstract}' not found." ) ; }
Invokes the registered entry for an abstract and returns the result .
16,074
private function retrieve ( & $ from , $ abstract , $ args = [ ] ) { $ entry = $ from [ $ abstract ] ; if ( is_object ( $ entry ) && ( $ entry instanceof \ Closure ) ) { return $ this -> invoke ( $ entry , $ args ) ; } return $ entry ; }
Helper method to retrieve an existing entry from a given library array . You have to find sure that the entry exists in the library .
16,075
public function make ( $ concrete , array $ args = [ ] ) { if ( ! is_object ( $ concrete ) && ! is_scalar ( $ concrete ) && ! is_null ( $ concrete ) ) { throw new Exceptions \ InvalidArgumentException ( ) ; } $ reflection = new \ ReflectionClass ( $ concrete ) ; $ constructor = $ reflection -> getConstructor ( ) ; $ arguments = $ constructor ? $ this -> inject ( $ constructor , $ args ) : [ ] ; return $ reflection -> newInstanceArgs ( $ arguments ) ; }
Make a new instance of a concrete using Dependency Injection .
16,076
public function invoke ( Callable $ callable , array $ args = [ ] ) { if ( is_string ( $ callable ) && false !== strpos ( $ callable , '::' ) ) { $ callable = explode ( '::' , $ callable ) ; } if ( is_array ( $ callable ) ) { $ reflection = new \ ReflectionMethod ( $ callable [ 0 ] , $ callable [ 1 ] ) ; } if ( ! isset ( $ reflection ) ) { $ reflection = new \ ReflectionFunction ( $ callable ) ; } $ arguments = $ this -> inject ( $ reflection , $ args ) ; return $ callable ( ... $ arguments ) ; }
Invoke the given Closure with DI .
16,077
protected function inject ( \ ReflectionFunctionAbstract $ reflection , array $ args = [ ] ) { $ parameters = $ reflection -> getParameters ( ) ; $ arguments = [ ] ; foreach ( $ parameters as $ parameter ) { $ class = $ parameter -> getClass ( ) ; $ key = $ class && isset ( $ args [ $ class -> name ] ) ? $ class -> name : $ parameter -> name ; if ( array_key_exists ( $ key , $ args ) ) { $ arguments [ ] = $ args [ $ key ] ; unset ( $ args [ $ key ] ) ; continue ; } if ( $ class && $ this -> delegate -> has ( $ class -> name ) ) { $ arguments [ ] = $ this -> delegate -> get ( $ class -> name ) ; continue ; } if ( $ class && class_exists ( $ class -> name ) ) { $ arguments [ ] = $ this -> make ( $ class -> name ) ; continue ; } if ( $ parameter -> isDefaultValueAvailable ( ) ) { $ arguments [ ] = $ parameter -> getDefaultValue ( ) ; continue ; } throw new Exceptions \ ParameterResolutionException ( $ reflection , $ parameter ) ; } return $ arguments ; }
Performs the actual injection of dependencies from a reflection
16,078
public static function createService ( Application $ app , $ serviceName , $ pathName , $ optionsName ) { $ app [ $ optionsName ] = array ( ) ; $ app [ $ serviceName ] = $ app -> share ( function ( ) use ( $ app , $ serviceName , $ pathName , $ optionsName ) { $ app [ $ optionsName ] = array_merge ( array ( 'cache_path' => '' , 'debug' => $ app [ 'debug' ] , 'prefix' => $ app [ 'debug' ] ? 'dev.' : 'prod.' ) , $ app [ $ optionsName ] ) ; if ( false === isset ( $ app [ $ optionsName ] [ 'loaders' ] ) ) { $ options = $ app [ $ optionsName ] ; $ options [ 'loaders' ] = array ( 'KevinGH\Wisdom\Loader\INI' , 'KevinGH\Wisdom\Loader\JSON' ) ; if ( class_exists ( 'Symfony\Component\Yaml\Yaml' ) ) { $ options [ 'loaders' ] [ ] = 'KevinGH\Wisdom\Loader\YAML' ; } $ app [ $ optionsName ] = $ options ; } $ wisdom = new Wisdom ( $ app [ $ pathName ] ) ; $ wisdom -> setCache ( $ app [ $ optionsName ] [ 'cache_path' ] ) ; $ wisdom -> setDebug ( $ app [ $ optionsName ] [ 'debug' ] ) ; $ wisdom -> setPrefix ( $ app [ $ optionsName ] [ 'prefix' ] ) ; $ wisdom -> setValues ( $ app ) ; foreach ( ( array ) $ app [ $ optionsName ] [ 'loaders' ] as $ class ) { $ wisdom -> addLoader ( new $ class ) ; } return $ wisdom ; } ) ; }
Creates a Wisdom service provider .
16,079
public function pipe ( ExecutableInterface $ process , $ _ = null ) { foreach ( func_get_args ( ) as $ index => $ process ) { if ( $ process instanceof ExecutableInterface ) { $ this -> processes [ ] = $ process ; } else { $ message = 'Argument ' . $ index . ' passed to ' . __METHOD__ . '() must implement interface ' . 'Net\Bazzline\Component\ProcessPipe\ExecutableInterface' . ', instance of ' . get_class ( $ process ) . ' given' ; throw new InvalidArgumentException ( $ message ) ; } } return $ this ; }
Adds one or more process to the pipe
16,080
public static function make_assoc ( $ columns , $ array ) { $ assoc = array ( ) ; $ cursor = 0 ; foreach ( $ array as $ record ) { foreach ( $ record as $ key => $ value ) { $ assoc [ $ cursor ] [ $ columns [ $ key ] ] = $ value ; } $ cursor ++ ; } return $ assoc ; }
Convert an array into an associative array
16,081
public static function group_concat ( $ data , $ column , $ strings = false , $ quotes = '\'' ) { if ( is_string ( $ column ) ) { $ column = array ( $ column ) ; } $ return = array ( ) ; foreach ( $ column as $ col ) { $ return [ $ col ] = ( $ strings ? $ quotes : '' ) ; } foreach ( $ data as $ row ) { foreach ( $ column as $ col ) { $ return [ $ col ] .= $ row [ $ col ] . ( $ strings ? ( $ quotes . ',' . $ quotes ) : ',' ) ; } } foreach ( $ return as $ column => $ ret ) { if ( ( $ length = strlen ( $ ret ) ) < 1 ) continue ; $ trim = 1 ; if ( $ strings ) { $ trim = strlen ( $ quotes ) + 1 ; } $ return [ $ column ] = substr ( $ ret , 0 , $ length - $ trim ) ; } return $ return ; }
emulate the MySql group concat function for a result set
16,082
public static function value_to_key ( $ data , $ column ) { $ return = array ( ) ; foreach ( $ data as $ key => $ val ) { if ( is_object ( $ val ) ) { $ return [ $ val -> $ column ] = $ val ; } else { $ return [ $ val [ $ column ] ] = $ val ; } } return $ return ; }
column of array to key
16,083
public function filter ( $ value ) { if ( ! is_scalar ( $ value ) ) { return $ value ; } $ value = ( string ) $ value ; $ defaultScheme = $ this -> defaultScheme ? : $ this -> enforcedScheme ; if ( ! UriFactory :: getRegisteredSchemeClass ( $ defaultScheme ) ) { $ defaultScheme = null ; } try { $ uri = UriFactory :: factory ( $ value , $ defaultScheme ) ; if ( $ this -> enforcedScheme && ( ! $ uri -> getScheme ( ) ) ) { $ this -> enforceScheme ( $ uri ) ; } } catch ( UriException $ ex ) { return $ value ; } $ uri -> normalize ( ) ; if ( ! $ uri -> isValid ( ) ) { return $ value ; } return $ uri -> toString ( ) ; }
Filter the URL by normalizing it and applying a default scheme if set
16,084
protected function enforceScheme ( Uri $ uri ) { $ path = $ uri -> getPath ( ) ; if ( strpos ( $ path , '/' ) !== false ) { list ( $ host , $ path ) = explode ( '/' , $ path , 2 ) ; $ path = '/' . $ path ; } else { $ host = $ path ; $ path = '' ; } if ( ! $ host ) { return ; } $ uri -> setScheme ( $ this -> enforcedScheme ) -> setHost ( $ host ) -> setPath ( $ path ) ; }
Enforce the defined scheme on the URI
16,085
public function insert ( & $ data , array $ options = array ( ) ) { $ document = new Document ( $ data , $ this ) ; $ insert = $ document -> insert ( $ options ) ; $ data = $ document -> data ; return $ insert ; }
Insert new document
16,086
public function findAndModify ( array $ query , array $ update = array ( ) , array $ fields = null , array $ options = array ( ) ) { $ document = new Document ( $ query , $ this ) ; $ findAndModify = $ document -> findAndModify ( $ update , $ fields , $ options ) ; return $ findAndModify ; }
Find and Modify Document
16,087
public function getShort ( $ full ) { if ( strpos ( $ full , '*' ) !== false ) { return $ this -> schema_index [ substr ( $ full , 0 , - 2 ) ] . '.*' ; } if ( isset ( $ this -> schema [ $ full ] [ 'short' ] ) ) { return $ this -> schema [ $ full ] [ 'short' ] ; } return $ full ; }
Get short definitions based on full key
16,088
public static function create ( Request $ request , Response $ response = null , Exception $ previous = null ) { if ( ! $ response ) { return new self ( 'Error completing request' , $ request , null , $ previous ) ; } $ code = $ response -> getStatusCode ( ) ; switch ( $ code [ 0 ] ) { case '4' : $ message = 'Client Error' ; break ; case '5' : $ message = 'Server Error' ; break ; default : $ message = 'Unknown Error' ; break ; } return new self ( $ message , $ request , $ response , $ previous ) ; }
Creates a new exception based on input data
16,089
public function getScalarRecords ( SimpleXMLElement $ element , $ asArray = true ) { $ data = [ ] ; if ( $ element -> count ( ) ) { foreach ( $ element -> children ( ) as $ name => $ property ) { if ( ! $ property -> count ( ) ) { $ data [ $ name ] = ( string ) $ property ; } } return $ data ; } elseif ( $ asArray ) { return [ $ element -> getName ( ) => ( string ) $ element ] ; } else { return ( string ) $ element ; } }
Get all the Scalar records in the current element . Ignore all nested data . The XPaths should be used to include this data .
16,090
public function parse ( ) { if ( ! count ( $ this -> xPaths ) ) { return [ [ ] ] ; } $ xPaths = $ this -> xPaths ; return $ this -> parseXPath ( $ xPaths , $ this -> xml ) ; }
Start the Fusing process Using the XPaths try to merge nested data with child data recursively
16,091
public function setAttribs ( array $ aAttribs ) { if ( ! isset ( $ aAttribs [ 'method' ] ) ) $ aAttribs [ 'method' ] = 'POST' ; $ aAttribs [ 'class' ] = isset ( $ aAttribs [ 'class' ] ) ? $ aAttribs [ 'class' ] . ' sked-form' : 'sked-form' ; $ this -> aAttribs = $ aAttribs ; return $ this ; }
Set the HTML element attributes .
16,092
public function setSkeVent ( $ skeVent ) { if ( is_array ( $ skeVent ) ) $ skeVent = new SkeVent ( $ skeVent ) ; $ this -> skeVent = $ skeVent ; return $ this ; }
Save event object for populating defaults .
16,093
public function inputs ( ) { $ aReturn = [ ] ; foreach ( $ this -> getFieldDefinitions ( ) as $ strFieldName => $ aField ) { $ skeFormInput = new SkeFormInput ( $ strFieldName , $ aField [ 'type' ] ?? 'text' , $ aField [ 'options' ] ?? [ ] , $ aField [ 'attribs' ] ?? [ ] ) ; if ( $ this -> skeVent ) { $ skeFormInput -> setValue ( $ this -> skeVent -> getProperty ( $ strFieldName ) ) ; if ( $ this -> skeVent -> hasError ( $ strFieldName ) ) $ skeFormInput -> setError ( $ this -> skeVent -> getError ( $ strFieldName ) ) ; } $ aReturn [ ] = $ skeFormInput ; } return $ aReturn ; }
Get inputs for SkeVent form .
16,094
public function checkPassword ( ) : bool { if ( ! isset ( $ this -> regex ) ) { return true ; } return filter_var ( $ this -> password , FILTER_VALIDATE_REGEXP , [ 'options' => [ 'regexp' => $ this -> regex ] ] ) ; }
Checks the password agains the set regex and returns the boolean result of this check
16,095
public function get_data ( $ priority = null ) { if ( $ priority === null ) { return $ this -> data ; } if ( isset ( $ this -> data [ $ priority ] ) ) { return $ this -> data [ $ priority ] ; } return [ ] ; }
Return all data for the hook .
16,096
private function generate_hook_info ( $ type , $ reflector , $ args ) { $ output = [ 'type' => $ type , 'file_name' => $ reflector -> getFileName ( ) , 'line_number' => $ reflector -> getStartLine ( ) , 'class' => null , 'name' => null , 'is_internal' => false , ] ; if ( $ reflector instanceof ReflectionMethod ) { $ output [ 'class' ] = $ reflector -> getDeclaringClass ( ) -> getName ( ) ; } if ( 'Closure' !== $ type ) { $ output [ 'name' ] = $ reflector -> getName ( ) ; $ output [ 'is_internal' ] = $ reflector -> isInternal ( ) ; } $ output [ 'accepted_args' ] = $ args ; return $ output ; }
Generate output for a hook callback .
16,097
protected function extractMessagesForDisplay ( & $ messages ) { $ output = [ ] ; if ( empty ( $ messages ) || count ( $ messages ) == 0 ) { return $ output ; } foreach ( $ messages as $ current ) { $ message_entry [ "message" ] = $ current [ "message" ] ; if ( ! empty ( $ current [ "code" ] ) ) { $ message_entry [ "code" ] = $ current [ "code" ] ; } if ( ! empty ( $ current [ "auto_hide" ] ) ) { $ message_entry [ "auto_hide" ] = $ this -> getAutoHideTime ( ) ; } if ( ! empty ( $ current [ "details" ] ) && config_settings ( ) -> getParameter ( "show_message_details" , false , 1 ) ) { $ message_entry [ "details" ] = $ current [ "details" ] ; } $ output [ ] = $ message_entry ; } $ messages = null ; return $ output ; }
This is internal auxiliary function for preparing messags for displaying .
16,098
public function getFocusElement ( ) { if ( empty ( self :: $ session_vars [ "focus_element" ] ) ) { return "" ; } $ felm = self :: $ session_vars [ "focus_element" ] ; unset ( self :: $ session_vars [ "focus_element" ] ) ; return $ felm ; }
Returns the element to be focused .
16,099
public function getActiveTab ( ) { if ( empty ( self :: $ session_vars [ "active_tab" ] ) ) { return "" ; } $ atab = self :: $ session_vars [ "active_tab" ] ; unset ( self :: $ session_vars [ "active_tab" ] ) ; return $ atab ; }
Returns the tab to be activated .