idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
17,900 | public function listFiles ( $ directory = null , $ recursive = false ) { return $ this -> flysystem -> listFiles ( $ directory , $ recursive ) ; } | List all the files from a directory |
17,901 | public function addHeader ( string $ name , string $ value ) : bool { $ isSet = false ; if ( ! empty ( $ name ) && ! empty ( $ value ) ) { $ this -> offsetSet ( $ name , $ value ) ; $ isSet = true ; } return $ isSet ; } | Adds a new Header . If the header already exists it is overwritten . |
17,902 | public function methodExcludedByOptions ( $ method , array $ options ) { return ( ! empty ( $ options [ 'only' ] ) && ! in_array ( $ method , ( array ) $ options [ 'only' ] ) ) || ( ! empty ( $ options [ 'except' ] ) && in_array ( $ method , ( array ) $ options [ 'except' ] ) ) ; } | Determine if the given options exclude a particular method . |
17,903 | protected function filterFailsOn ( $ filter , $ request , $ method ) { $ on = array_get ( $ filter , 'options.on' ) ; if ( is_null ( $ on ) ) return false ; if ( is_string ( $ on ) ) $ on = explode ( '|' , $ on ) ; return ! in_array ( strtolower ( $ request -> getMethod ( ) ) , $ on ) ; } | Determine if the filter fails the on constraint . |
17,904 | public static function uniqueId ( ) : string { $ rand = random_bytes ( 16 ) ; $ rand [ 6 ] = chr ( ord ( $ rand [ 6 ] ) & 0x0f | 0x40 ) ; $ rand [ 8 ] = chr ( ord ( $ rand [ 8 ] ) & 0x3f | 0x80 ) ; $ rand = str_split ( bin2hex ( $ rand ) , 4 ) ; return vsprintf ( '%s%s%s%s%s' , array_map ( function ( $ hex ) { return b... | Follow uuid v4 generation standard but remove dash and encode in base 32 Guarantee 128 bits of entropy but use ~ 20% less space compare to base 16 |
17,905 | public static function initialize ( $ group_name , $ access_token , $ opts = null ) { if ( ! is_string ( $ group_name ) || strlen ( $ group_name ) == 0 ) { throw new Exception ( "Invalid group_name" ) ; } if ( ! is_string ( $ access_token ) || strlen ( $ access_token ) == 0 ) { throw new Exception ( "Invalid access_tok... | Initializes and returns the singleton instance of the Runtime . |
17,906 | public static function getInstance ( $ group_name = NULL , $ access_token = NULL , $ opts = NULL ) { if ( ! isset ( self :: $ _singleton ) ) { self :: $ _singleton = self :: newRuntime ( $ group_name , $ access_token , $ opts ) ; } return self :: $ _singleton ; } | Returns the singleton instance of the Runtime . |
17,907 | public static function newRuntime ( $ group_name , $ access_token , $ opts = NULL ) { if ( is_null ( $ opts ) ) { $ opts = array ( ) ; } if ( $ group_name != NULL ) { $ opts [ 'group_name' ] = $ group_name ; } if ( $ group_name != NULL ) { $ opts [ 'access_token' ] = $ access_token ; } return new TraceguideBase \ Clien... | Creates a new runtime instance . |
17,908 | public static function merge ( $ a , $ b ) { $ acon = static :: parse ( $ a ) ; $ bcon = static :: parse ( $ b ) ; if ( $ acon instanceof EmptyConstraint ) { return $ b ; } elseif ( $ bcon instanceof EmptyConstraint ) { return $ a ; } elseif ( $ acon -> matches ( $ bcon ) || $ bcon -> matches ( $ acon ) ) { return strl... | Merges two constraints . Doesn t resolve version conflicts . |
17,909 | public function array_fields ( $ array , array $ fields ) { $ newArray = array ( ) ; foreach ( $ array as $ value ) { $ newValue = array ( ) ; foreach ( $ fields as $ key ) { if ( array_key_exists ( $ key , $ value ) ) { $ newValue [ $ key ] = $ value [ $ key ] ; } } $ newArray [ ] = $ newValue ; } return $ newArray ; ... | Retorna un array con los campos indicados |
17,910 | public function json_encode_data ( $ object , array $ fields , $ options = 0 ) { $ array = $ this -> object_to_array ( $ object , $ fields ) ; return json_encode ( $ array , $ options ) ; } | Este realiza el pasaje de un objeto a json asegurando que el mismo no entre en loop . Para esto primero pasa el objeto a array en base a los campos que quiere mapear y despues lo pasa a json |
17,911 | public function json_encode_recursion ( $ object , $ recursionLevel = 1 , $ options = 0 ) { $ objects = array ( ) ; $ ocurrencias = array ( ) ; $ array = array ( ) ; if ( is_array ( $ object ) ) { $ array = $ object ; foreach ( $ array as & $ var ) { $ var = $ this -> json_encode_recursion_internal ( $ var , $ recursio... | Este metodo realiza el pasaje de un objeto Doctrine a json . Para esto indicamos el nivel de profundidad que se va a ingresar en el objeto y los objetos no cargados hasta el momento solo se mapearan su id . |
17,912 | protected function json_encode_recursion_internal ( $ object , $ recursionLevel = 1 , $ options = 0 , $ objects , $ ocurrencias ) { $ pos = array_search ( $ object , $ objects ) ; $ repeticiones = 1 ; if ( $ pos !== FALSE ) { $ ocurrencias [ $ pos ] ++ ; $ repeticiones = $ ocurrencias [ $ pos ] ; } else { $ objects [ ]... | Este metodo es privado y realiza el pasaje de un objeto Doctrine a json . Para esto indicamos el nivel de profundidad que se va a ingresar en el objeto y los objetos no cargados hasta el momento solo se mapearan su id . |
17,913 | public function attach ( Registry $ registry , $ id = '' ) { if ( ! empty ( $ id ) || 0 === $ id ) { if ( ! empty ( $ this -> registries [ $ id ] ) ) { throw new RegistryException ( RegistryException :: DUPLICATE_REGISTRATION_ATTEMPT_TEXT , RegistryException :: DUPLICATE_REGISTRATION_ATTEMPT_CODE ) ; } $ this -> regist... | Adds the provided registry to the dispatcher queue . |
17,914 | public function detach ( $ id ) { if ( empty ( $ this -> registries [ $ id ] ) ) { throw new RegistryException ( RegistryException :: MODIFICATION_ATTEMPT_FAILED_TEXT , RegistryException :: MODIFICATION_ATTEMPT_FAILED_CODE ) ; } unset ( $ this -> registries [ $ id ] ) ; } | Removes the a registry from dispatcher . |
17,915 | protected function processRegistry ( $ action , Registry $ registry , $ id , array $ output , array $ args = array ( ) ) { try { $ output [ $ id ] = call_user_func_array ( array ( $ registry , $ action ) , $ args ) ; } catch ( RegistryException $ e ) { $ this -> errors [ $ id ] = $ e ; } return $ output ; } | Invokes the defined callback on the given registry . |
17,916 | public function getLastErrorMessages ( ) { $ message = '' ; if ( $ this -> hasError ( ) ) { foreach ( $ this -> errors as $ exception ) { $ message .= $ exception -> getMessage ( ) . ',' . PHP_EOL ; } } return $ message ; } | Provides the messages generated by the last occurred errors . |
17,917 | protected function fetchArray ( $ cursor = null ) { if ( ! empty ( $ cursor ) && $ cursor instanceof Statement ) { return $ cursor -> fetch ( \ PDO :: FETCH_NUM ) ; } if ( $ this -> prepared instanceof Statement ) { return $ this -> prepared -> fetch ( \ PDO :: FETCH_NUM ) ; } } | Method to fetch a row from the result set cursor as an array . |
17,918 | protected function fetchAssoc ( $ cursor = null ) { if ( ! empty ( $ cursor ) && $ cursor instanceof Statement ) { return $ cursor -> fetch ( \ PDO :: FETCH_ASSOC ) ; } if ( $ this -> prepared instanceof Statement ) { return $ this -> prepared -> fetch ( \ PDO :: FETCH_ASSOC ) ; } return null ; } | Method to fetch a row from the result set cursor as an associative array . |
17,919 | public function loadNextObject ( $ class = 'stdClass' ) { $ this -> connect ( ) ; if ( ! $ this -> executed ) { if ( ! ( $ this -> execute ( ) ) ) { return $ this -> errorNum ? null : false ; } } if ( $ row = $ this -> fetchObject ( null , $ class ) ) { return $ row ; } $ this -> freeResult ( ) ; return false ; } | Method to get the next row in the result set from the database query as an object . |
17,920 | public function escape ( $ text , $ extra = false ) { if ( is_int ( $ text ) || is_float ( $ text ) ) { return $ text ; } $ result = substr ( $ this -> connection -> quote ( $ text ) , 1 , - 1 ) ; if ( $ extra ) { $ result = addcslashes ( $ result , '%_' ) ; } return $ result ; } | Escapes a string for usage in an SQL statement . |
17,921 | public static function encode ( String $ str ) : String { return preg_replace ( array_keys ( self :: $ scriptTagChars ) , array_values ( self :: $ scriptTagChars ) , $ str ) ; } | Encode Script Tags |
17,922 | public static function decode ( String $ str ) : String { return preg_replace ( array_keys ( self :: $ scriptTagCharsDecode ) , array_values ( self :: $ scriptTagCharsDecode ) , $ str ) ; } | Decode Script Tags |
17,923 | function parseBody ( ) { $ request = $ this -> getMessageObject ( ) ; $ reqID = spl_object_hash ( $ request ) ; if ( isset ( self :: $ _parsed [ $ reqID ] ) ) return self :: $ _parsed [ $ reqID ] ; if ( $ request -> headers ( ) -> has ( 'content-type' ) ) { $ contentType = \ Poirot \ Http \ Header \ renderHeaderValue (... | Parse Request Body Data |
17,924 | function parseQueryParams ( ) { $ request = $ this -> getMessageObject ( ) ; $ data = array ( ) ; $ url = $ request -> getTarget ( ) ; if ( $ p = parse_url ( $ url , PHP_URL_QUERY ) ) parse_str ( $ p , $ data ) ; return $ data ; } | Parse Request Query Params |
17,925 | public function getUrlAttribute ( ) { if ( $ this -> disk == 'public' ) { return url ( $ this -> storage -> url ( $ this -> path ) ) ; } return config ( 'media.download' , false ) ? url ( str_finish ( config ( 'media.download' ) , '/' ) . $ this -> id ) : null ; } | Url to file . |
17,926 | public function getFirstName ( ) : ? string { if ( ! $ this -> hasFirstName ( ) ) { $ this -> setFirstName ( $ this -> getDefaultFirstName ( ) ) ; } return $ this -> firstName ; } | Get first name |
17,927 | private function isUnixTimestamp ( $ value ) : bool { return ( string ) ( float ) $ value == ( string ) $ value && ( ( float ) $ value <= PHP_INT_MAX ) && ( ( float ) $ value >= ~ PHP_INT_MAX ) ; } | Checks whether a value is a valid UNIX timestamp |
17,928 | private function validateDateTime ( $ value ) : void { try { if ( is_a ( $ value , DateTime :: class ) || is_null ( $ value ) || $ value === 'now' ) { } else { if ( $ this -> isUnixTimestamp ( $ value ) ) { DateTime :: createFromFormat ( "U.u" , $ this -> unixTimestampAsUuFormat ( $ value ) ) ; } else { new DateTime ( ... | Validates a value as a nullable value that can be cast to DateTime |
17,929 | public function goSide ( $ fileName ) : parent { $ filePath = $ this -> htsl -> getFilePath ( $ fileName , dirname ( $ this -> filePath ) ) ; $ content = $ this -> htsl -> getFileContent ( $ filePath ) ; return new static ( $ this -> htsl , $ content , $ filePath ) ; } | Getting another file reference fake file of this buffer . |
17,930 | private function connect ( ) { try { $ this -> db = new \ PDO ( $ this -> dbOptions [ 'dsn' ] , $ this -> dbOptions [ 'username' ] , $ this -> dbOptions [ 'password' ] , $ this -> dbOptions [ 'driver_options' ] ) ; } catch ( \ Exception $ e ) { if ( $ this -> dbOptions [ 'debug' ] ) { throw $ e ; } else { throw new \ P... | Internal function for connecting to the database |
17,931 | private function checkValidity ( ) { if ( ! is_writable ( $ this -> rssFile ) ) { $ this -> valid = false ; return ; } $ stmt = $ this -> db -> prepare ( 'SELECT CREATED FROM ' . $ this -> table . ' ORDER BY CREATED DESC LIMIT 1' ) ; $ stmt -> execute ( ) ; $ res = $ stmt -> fetchAll ( ) ; if ( count ( $ res ) == 0 ) {... | Compares RSS file created timestamp and database timestamp to judge if new RSS file is needed |
17,932 | private function createRSS ( ) { $ file = fopen ( $ this -> rssFile , "w+" ) ; $ stmt = $ this -> db -> prepare ( 'SELECT * FROM ' . $ this -> table . ' ORDER BY CREATED DESC LIMIT ?' ) ; $ stmt -> execute ( [ $ this -> newsCount ] ) ; $ res = $ stmt -> fetchAll ( ) ; $ xmlVersion = '<?xml version="1.0" encoding="UTF-8... | Creates a new RSS File with information from the database . Max amount of news is configured in the initiation . |
17,933 | public function getRSS ( ) { $ this -> checkValidity ( ) ; if ( ! $ this -> valid ) { $ this -> createRSS ( ) ; } if ( $ this -> sendHeader ) { header ( 'Content-type: application/rss+xml; charset=UTF-8' ) ; } readfile ( $ this -> rssFile ) ; } | Function that should be called to receive the RSS feed . Checks if the latest RSS File is up to date if not generates a new one . |
17,934 | public static function validate ( $ result , array $ context ) { if ( ! empty ( $ context [ 'parent' ] ) ) { if ( ! ( $ result instanceof $ context [ 'parent' ] ) ) { throw new InvalidPointer ( 'Object must be an instance of ' . $ context [ 'parent' ] ) ; } } if ( ! empty ( $ context [ 'validator' ] ) ) { if ( ! Callba... | Checks a result |
17,935 | protected function removeFromQueue ( PriorityQueueInterface $ queue , $ callabOrClassname ) { if ( is_object ( $ callabOrClassname ) ) { $ queue -> remove ( $ callabOrClassname ) ; } else { foreach ( $ queue as $ data ) { if ( is_a ( $ data [ 'data' ] , $ callabOrClassname ) ) { $ queue -> remove ( $ data [ 'data' ] ) ... | Remove callable or matching classname object from the queue |
17,936 | protected function runProcessors ( LogEntryInterface $ logEntry ) { $ queue = $ this -> getCallables ( 'processors' , $ logEntry -> getChannel ( ) ) ; foreach ( $ queue as $ data ) { call_user_func ( $ data [ 'data' ] , $ logEntry ) ; } return $ this ; } | Execute related processors on the log entry |
17,937 | protected function runHandlers ( LogEntryInterface $ logEntry ) { $ queue = $ this -> getCallables ( 'handlers' , $ logEntry -> getChannel ( ) ) ; foreach ( $ queue as $ data ) { if ( $ logEntry -> isPropagationStopped ( ) ) { break ; } if ( LogLevel :: $ levels [ $ logEntry -> getLevel ( ) ] >= LogLevel :: $ levels [ ... | Execute related handlers on the log entry |
17,938 | public function executeAndFetch ( $ query , $ parameters = [ ] , $ castModel = null ) { $ statement = $ this -> link -> prepare ( $ query ) ; $ statement -> execute ( $ parameters ) ; $ data = $ statement -> fetch ( PDO :: FETCH_ASSOC ) ; $ statement -> closeCursor ( ) ; return ( $ castModel && $ data ? $ data : $ data... | Execute a query and fetch first row as associative array |
17,939 | public function bindExecuteAndFetch ( $ query , $ parameters = [ ] , $ castModel = null ) { $ statement = $ this -> link -> prepare ( $ query ) ; foreach ( $ parameters as $ index => $ paramProperties ) { if ( is_object ( $ paramProperties ) ) { $ paramProperties = ( array ) $ paramProperties ; } if ( is_array ( $ para... | Bind Execute a query and fetch first row as associative array |
17,940 | public function bindExecuteAndFetchAll ( $ query , $ parameters = [ ] , $ castModel = null ) { $ statement = $ this -> link -> prepare ( $ query ) ; foreach ( $ parameters as $ index => $ paramProperties ) { if ( is_object ( $ paramProperties ) ) { $ paramProperties = ( array ) $ paramProperties ; } if ( is_array ( $ p... | Bind Execute a query and fetch all rows as associative array |
17,941 | public function getById ( $ id ) { $ id = ( int ) $ id ; $ rowSet = $ this -> getTableGateway ( ) -> select ( [ $ this -> getPrimaryKey ( ) => $ id ] ) ; $ row = $ rowSet -> current ( ) ; return $ row ; } | Get one row by it s id |
17,942 | public function fetchAll ( $ paginated = false ) { if ( $ paginated ) { $ paginatorAdapter = new DbTableGateway ( $ this -> tableGateway ) ; $ paginator = new Paginator ( $ paginatorAdapter ) ; return $ paginator ; } $ resultSet = $ this -> getTableGateway ( ) -> select ( ) ; return $ resultSet ; } | Fetch all records . |
17,943 | public function findByUri ( $ uri ) { return $ this -> routes -> first ( function ( $ route ) use ( $ uri ) { return $ route -> match ( $ uri ) ; } ) ; } | Finds the route via uri |
17,944 | public function findByName ( $ name ) { return $ this -> routes -> first ( function ( $ route ) use ( $ name ) { return $ route -> getName ( ) === $ name ; } ) ; } | Returns route by given name |
17,945 | public function group ( array $ options , \ Closure $ closure ) { $ group = new static ( null , $ options ) ; $ closure -> bindTo ( $ group ) -> __invoke ( $ group ) ; $ this -> getCollection ( ) -> addAll ( $ group -> getCollection ( ) ) ; return $ this ; } | Create a group with specific options |
17,946 | public function routable ( $ class , $ prefix = null ) { $ class = $ this -> resolveRoutableClassValue ( $ class ) ; $ router = ( new RoutableInspector ( $ class ) ) -> generateRoutables ( null , $ prefix ) ; $ this -> mergeRouter ( $ router ) ; return $ this ; } | Import all routable method for a class |
17,947 | protected function resolveNameValue ( $ name ) { if ( $ name === null ) return null ; if ( $ prefixName = $ this -> getPrefixName ( ) ) { $ name = $ prefixName . $ name ; } return $ name ; } | Result value of name |
17,948 | public function setOptions ( array $ args ) { $ this -> options = $ args += [ 'filters' => [ ] , 'name' => null , 'namespace' => null , 'prefix' => null , ] ; $ args [ 'namespace' ] && $ this -> setNamespace ( $ args [ 'namespace' ] ) ; $ args [ 'prefix' ] && $ this -> setPrefixPath ( $ args [ 'prefix' ] ) ; $ args [ '... | Set value via array options |
17,949 | public function acfLocationRulesMatch ( $ match , $ rule , $ options ) { $ post_types = get_field ( 'easy_reading_posttypes' , 'option' ) ; if ( $ post_types ) { if ( $ rule [ 'operator' ] == "==" ) { $ match = ( isset ( $ options [ 'post_type' ] ) && in_array ( $ options [ 'post_type' ] , $ post_types ) && $ options [... | Matching custom location rule |
17,950 | public function getUriWithExtraString ( string $ uri ) : String { if ( ! $ this -> queryString ) { return $ uri ; } return $ uri . '?' . implode ( '&' , $ this -> queryString ) ; } | Get uri with extra query strings |
17,951 | public function go ( $ input ) { Arguments :: define ( Boa :: readMap ( ) ) -> define ( $ input ) ; $ map = ComplexFactory :: toReadMap ( $ this -> functions ) ; if ( $ map -> member ( $ input ) ) { $ function = Maybe :: fromJust ( $ map -> lookup ( $ input ) ) ; return $ function ( ) ; } elseif ( $ map -> member ( $ t... | Run the flick on input . |
17,952 | public static function slugify ( $ string ) { $ string = strtolower ( preg_replace ( array ( '/[^a-zA-Z0-9 -]/' , '/[ -]+/' , '/^-|-$/' ) , array ( '' , '-' , '' ) , $ string ) ) ; $ string = ltrim ( $ string , "-" ) ; $ string = rtrim ( $ string , '-' ) ; return $ string ; } | Turn a string into a slug |
17,953 | public static function toTitleCase ( $ string ) { $ string = str_replace ( [ "_" , "-" ] , " " , $ string ) ; $ name_array = explode ( " " , $ string ) ; $ smallWords = [ 'of' , 'a' , 'the' , 'and' , 'an' , 'or' , 'nor' , 'but' , 'is' , 'if' , 'then' , 'else' , 'when' , 'at' , 'from' , 'by' , 'on' , 'off' , 'for' , 'in... | Format a string into title case |
17,954 | protected function publishRoute ( Filesystem $ filesystem , $ route ) { if ( is_null ( $ route ) ) { return ; } $ routeFile = app_path ( 'Http/routes.php' ) ; if ( $ filesystem -> exists ( $ routeFile ) && $ filesystem -> exists ( $ route ) ) { $ filesystem -> append ( $ routeFile , $ filesystem -> get ( $ route ) ) ; ... | Appends routes . |
17,955 | private function getProperty ( $ name ) { if ( ! Property :: exists ( $ this -> properties , $ name ) ) { throw new \ Exception ( ) ; } return Property :: get ( $ this -> properties , $ name ) ; } | Returns value of property |
17,956 | public static function getJSONErrorAsString ( ) { switch ( json_last_error ( ) ) { case JSON_ERROR_NONE : $ error = NULL ; break ; case JSON_ERROR_DEPTH : $ error = 'The maximum stack depth has been exceeded.' ; break ; case JSON_ERROR_STATE_MISMATCH : $ error = 'Invalid or malformed JSON.' ; break ; case JSON_ERROR_CT... | returns a string representation of the last JSON error |
17,957 | public static function containsValidJSON ( $ string ) { try { $ result = json_decode ( $ string ) ; } catch ( \ Exception $ e ) { } if ( self :: getJSONError ( ) === NULL ) return true ; else return false ; } | Determines if a string contains a valid decodable JSON object . |
17,958 | protected function getSettingsMethods ( ) { if ( empty ( $ this -> settingsMethods ) ) { $ settings = $ this -> getSettingsRepository ( ) ; $ methods = get_class_methods ( $ settings ) ; $ this -> settingsMethods = array_diff ( $ methods , [ '__construct' ] ) ; } return $ this -> settingsMethods ; } | Returns all accessible methods on the associated settings repository . |
17,959 | public function Log ( $ logMessage ) { $ target = null ; if ( $ user = Sentinel :: getUser ( ) ) if ( $ user != null ) $ target = $ user -> id ; $ log = $ this -> getLogsRepository ( ) -> create ( [ 'log' => $ logMessage , 'ip' => Request :: ip ( ) , 'target' => $ target ] ) ; } | Create a log |
17,960 | public function TargettedLog ( $ logMessage , $ userTarget ) { $ log = $ this -> getLogsRepository ( ) -> create ( [ 'log' => $ logMessage , 'target' => $ userTarget , 'ip' => Request :: ip ( ) ] ) ; } | Create a log and associates it to a user |
17,961 | public function setConfigByFile ( $ name ) { $ file = "/{$name}.cfg.php" ; if ( 'production' !== FS2_ENV ) { $ file_env = "/{$name}-{FS2_ENV}.cfg.php" ; if ( file_exists ( FS2CONFIG . $ file_env ) ) { $ file = $ file_env ; } } $ config = array ( ) ; if ( file_exists ( FS2CONFIG . "/" . $ file ) ) { include ( FS2CONFIG ... | set multiple config entries from a config file does not change any database data |
17,962 | public function autoloadPath ( $ path ) { $ files = glob ( $ path ) ; if ( $ files && count ( $ files ) ) { foreach ( $ files as $ file ) { if ( file_exists ( $ file ) && is_dir ( $ file ) ) { $ this -> autoloadPath ( $ file . "/*" ) ; } if ( file_exists ( $ file ) && is_file ( $ file ) ) { require_once ( $ file ) ; } ... | Autoloads all files in the given path |
17,963 | public function createView ( $ file = null ) { $ view = new View ( $ this -> getTemplatePath ( ) . '/app/views/' ) ; if ( $ file ) { $ view -> setFile ( $ file ) ; } return $ view ; } | Create a new View instance |
17,964 | public function init ( ) { $ coreViewPath = WP :: applyFilters ( 'wpmvc_core_views_path' , $ this -> getCorePath ( ) . '/Views/' ) ; $ appViewPath = WP :: applyFilters ( 'wpmvc_app_views_path' , $ this -> getTemplatePath ( ) . '/app/views/' ) ; $ theHeader = new View ( $ coreViewPath ) ; $ theBody = new View ( $ appVie... | Begin the routing |
17,965 | public function setTheme ( string $ theme ) { if ( ! $ this -> isPathValid ( $ theme ) ) { throw new NotFoundException ( 'The theme cannot be found.' ) ; } $ this -> validateTheme ( $ theme ) ; $ themeInfo = $ this -> getThemeInfo ( $ theme ) ; if ( array_key_exists ( 'parent' , $ themeInfo ) ) { $ this -> childTheme =... | Sets a theme |
17,966 | private function isPathValid ( string $ theme ) : bool { if ( ! is_dir ( rtrim ( $ this -> themePath , '/' ) . '/' . $ theme ) ) { return false ; } return true ; } | Checks whether the theme directory exists |
17,967 | private function validateTheme ( string $ theme ) { if ( ! file_exists ( $ this -> themePath . '/' . $ theme . '/info.json' ) ) { throw new InvalidException ( 'The theme (`' . $ theme . '`) is missing the configuration file (`info.json`).' ) ; } try { $ themeInfo = $ this -> getThemeInfo ( $ theme ) ; } catch ( \ Throw... | Checks whether the layout of the theme directory is valid |
17,968 | public function load ( string $ file ) : string { if ( $ this -> childTheme && file_exists ( $ this -> themePath . '/' . $ this -> childTheme [ 'name' ] . $ file ) ) { $ this -> preventDirectoryTraversal ( $ this -> themePath . '/' . $ this -> childTheme [ 'name' ] , $ this -> themePath . '/' . $ this -> childTheme [ '... | Loads a file from the theme |
17,969 | private function preventDirectoryTraversal ( string $ themePath , string $ filePath ) { $ themePath = realpath ( $ themePath ) ; $ filePath = realpath ( $ filePath ) ; if ( $ filePath === false || strpos ( $ filePath , $ themePath ) !== 0 ) { throw new DirectoryTraversalException ( 'Trying to load a file outside of the... | Validates the file path to prevent directory traversal |
17,970 | private function throwUnlessCorrectSubclass ( $ property , $ value ) { $ typeUsedToBe = $ this -> getTypeUsedToBe ( $ property ) ; if ( $ typeUsedToBe === "object" ) { $ classUsedToBe = $ this -> getClassUsedToBe ( $ property ) ; if ( ! is_subclass_of ( $ value , $ classUsedToBe ) ) { throw new Exception ( ) ; } } } | Throw Unless Correct Subclass |
17,971 | private function throwUnlessCorrectType ( $ property , $ value ) { $ typeUsedToBe = $ this -> getTypeUsedToBe ( $ property ) ; if ( $ typeUsedToBe !== "null" ) { $ typeWantsToBe = $ this -> getTypeWantsToBe ( $ value ) ; if ( $ typeUsedToBe !== $ typeWantsToBe ) { throw new Exception ( ) ; } } } | Throw Unless Correct Type |
17,972 | public static function create ( $ attributes , $ table , $ schema = null , $ return = self :: RETURN_ID ) { if ( is_object ( $ attributes ) ) { $ attributes = ( array ) $ attributes ; } $ driver = Database :: getAdapterName ( ) ; $ query_keys = implode ( '" , "' , array_keys ( $ attributes ) ) ; $ query_parameter_strin... | Create a new record in database |
17,973 | public function resolve ( $ resource ) { foreach ( $ this -> loaders ( ) as $ loader ) { if ( $ loader -> supports ( $ resource ) ) { return $ loader ; } } throw new LoaderException ( 'No matching loader found.' ) ; } | Resolve a loader . |
17,974 | public static function describe ( $ value ) : string { if ( is_array ( $ value ) ) { $ value = '<array>' ; } elseif ( is_object ( $ value ) || is_callable ( $ value ) || is_iterable ( $ value ) ) { $ value = sprintf ( '<%s>' , get_class ( $ value ) ) ; } else { $ value = ( string ) $ value ; if ( strlen ( $ value ) > 3... | Converts any value into a short descriptive label . |
17,975 | public function _copy ( $ srcFilePath , $ dstFilePath , $ fname = false ) { if ( $ fname ) $ fname .= "::_copy($srcFilePath, $dstFilePath)" ; else $ fname = "_copy($srcFilePath, $dstFilePath)" ; $ metaData = $ this -> _fetchMetadata ( $ srcFilePath , $ fname ) ; if ( ! $ metaData ) { return false ; } return $ this -> _... | Creates a copy of a file in DB + DFS |
17,976 | public function _purge ( $ filePath , $ onlyExpired = false , $ expiry = false , $ fname = false ) { if ( $ fname ) $ fname .= "::_purge($filePath)" ; else $ fname = "_purge($filePath)" ; $ sql = "DELETE FROM " . $ this -> dbTable ( $ filePath ) . " WHERE name_hash=" . $ this -> _md5 ( $ filePath ) ; if ( $ expiry !== ... | Purges meta - data and file - data for a file entry Will only expire a single file . Use _purgeByLike to purge multiple files |
17,977 | public function _purgeByLike ( $ like , $ onlyExpired = false , $ limit = 50 , $ expiry = false , $ fname = false ) { if ( $ fname ) $ fname .= "::_purgeByLike($like, $onlyExpired)" ; else $ fname = "_purgeByLike($like, $onlyExpired)" ; $ where = " WHERE name LIKE " . $ this -> _quote ( $ like ) ; if ( $ expiry !== fal... | Purges meta - data and file - data for files matching a pattern using a SQL LIKE syntax . This method should also remove the files from disk |
17,978 | public function _delete ( $ filePath , $ insideOfTransaction = false , $ fname = false ) { if ( $ fname ) $ fname .= "::_delete($filePath)" ; else $ fname = "_delete($filePath)" ; if ( $ insideOfTransaction ) { return $ this -> _deleteInner ( $ filePath , $ fname ) ; } else { return $ this -> _protect ( array ( $ this ... | Deletes a file from DB The file won t be removed from disk _purge has to be used for this . Only single files will be deleted to delete multiple files _deleteByLike has to be used . |
17,979 | protected function _deleteInner ( $ filePath , $ fname ) { if ( ! $ this -> _query ( "UPDATE " . $ this -> dbTable ( $ filePath ) . " SET mtime=-ABS(mtime), expired=1 WHERE name_hash=" . $ this -> _md5 ( $ filePath ) , $ fname ) ) $ this -> _fail ( "Deleting file $filePath failed" ) ; return true ; } | Callback method used by by _delete to delete a single file |
17,980 | public function _deleteByLike ( $ like , $ fname = false ) { if ( $ fname ) $ fname .= "::_deleteByLike($like)" ; else $ fname = "_deleteByLike($like)" ; return $ this -> _protect ( array ( $ this , '_deleteByLikeInner' ) , $ fname , $ like , $ fname ) ; } | Deletes multiple files using a SQL LIKE statement Use _delete if you need to delete single files |
17,981 | function _storeInner ( $ filePath , $ datatype , $ scope , $ fname ) { clearstatcache ( ) ; $ fileMTime = filemtime ( $ filePath ) ; $ contentLength = filesize ( $ filePath ) ; $ filePathHash = md5 ( $ filePath ) ; $ nameTrunk = self :: nameTrunk ( $ filePath , $ scope ) ; if ( $ this -> _insertUpdate ( $ this -> dbTab... | Callback function used to perform the actual file store operation |
17,982 | public function _getFileList ( $ scopes = false , $ excludeScopes = false , $ limit = false , $ path = false ) { $ filePathList = array ( ) ; $ tables = array_unique ( array ( $ this -> metaDataTable , $ this -> metaDataTableCache ) ) ; foreach ( $ tables as $ table ) { $ query = 'SELECT name FROM ' . $ table ; if ( is... | Gets the list of cluster files filtered by the optional params |
17,983 | protected function _selectOneRow ( $ query , $ fname , $ error = false , $ debug = false ) { return $ this -> _selectOne ( $ query , $ fname , $ error , $ debug , PDO :: FETCH_NUM ) ; } | Runs a select query and returns one numeric indexed row from the result If there are more than one row it will fail and exit if 0 it returns false . |
17,984 | protected function _selectOneAssoc ( $ query , $ fname , $ error = false , $ debug = false ) { return $ this -> _selectOne ( $ query , $ fname , $ error , $ debug , PDO :: FETCH_ASSOC ) ; } | Runs a select query and returns one associative row from the result . |
17,985 | public function permissionsToRegister ( ) { $ config = config ( 'acl' ) ; $ permissionPlaceholders = array_get ( $ config , 'permission_placeholders' ) ; $ additionalPermissions = array_get ( $ config , 'additional' ) ; $ permissionsToRegister = [ ] ; $ routes = array_filter ( $ this -> router -> getRoutes ( ) -> getRo... | Retreives the permissions to be registered . |
17,986 | public function load ( $ xmlString ) { $ data = $ this -> parserXml ( $ xmlString ) ; if ( ! isset ( $ data [ 'MsgType' ] ) ) { throw new \ RuntimeException ( "can not found MsgType" ) ; } if ( WxReceive :: MSG_TYPE_EVENT == $ data [ 'MsgType' ] ) { $ parser = new Event \ Parser ( ) ; return $ parser -> load ( $ data )... | parse xml string which come from WeChat server to WxReceiveMsg or WxReceiveEvent |
17,987 | protected function parserXml ( $ xmlString ) { libxml_disable_entity_loader ( true ) ; return json_decode ( json_encode ( simplexml_load_string ( $ xmlString , 'SimpleXMLElement' , LIBXML_NOCDATA ) , true ) , true ) ; } | parse xml to array |
17,988 | public function getAttribute ( $ name = null ) { return is_null ( $ name ) ? $ this -> attributes : Arr :: get ( $ this -> attributes , $ name ) ; } | Get variables for view |
17,989 | public function setView ( $ templateName , $ page , $ action , array $ attributes = [ ] , $ extension = "phtml" ) { $ this -> setTemplate ( $ templateName ) ; $ this -> setPage ( $ page ) ; $ this -> setAction ( $ action ) ; $ this -> setAttributes ( $ attributes ) ; $ this -> setExtension ( $ extension ) ; return $ th... | Set parameters for view |
17,990 | public function piece ( $ filePiece ) { $ filePiece = $ this -> viewPath . "{$filePiece}.{$this->extension}" ; if ( file_exists ( $ filePiece ) ) { include $ filePiece ; } else { MbException :: registerError ( new \ Exception ( "The file {$filePiece} not found!" ) ) ; } } | Get a piece to include in the view |
17,991 | public function getTranslation ( $ lang , $ create = false ) { foreach ( $ this -> translations as $ translation ) { if ( $ lang == $ translation -> getLang ( ) ) { return $ translation ; } } if ( $ create ) { $ class = $ this -> getTranslationClass ( ) ; $ translation = new $ class ( ) ; $ translation -> setLang ( $ l... | Returns the translation in a given language |
17,992 | public static function ofStaticMethod ( $ callable ) { if ( is_string ( $ callable ) and strpos ( $ callable , '::' ) !== false ) { $ callable = explode ( '::' , $ callable ) ; } if ( is_array ( $ callable ) and count ( $ callable ) === 2 ) { $ reflector = new \ ReflectionMethod ( $ callable [ 0 ] , $ callable [ 1 ] ) ... | Resolve if callable is static method |
17,993 | public static function ofClassMethod ( $ callable ) { if ( is_string ( $ callable ) and strpos ( $ callable , '::' ) !== false ) { $ callable = explode ( '::' , $ callable ) ; } if ( is_array ( $ callable ) and count ( $ callable ) === 2 ) { $ reflector = new \ ReflectionMethod ( $ callable [ 0 ] , $ callable [ 1 ] ) ;... | Resolve if callable is class method |
17,994 | public static function ofFunction ( $ callable ) { if ( $ callable instanceof \ Closure or ( is_string ( $ callable ) and function_exists ( $ callable ) ) ) { $ annotations = Annotation :: ofFunction ( $ callable ) ; $ reflector = new \ ReflectionFunction ( $ callable ) ; return new Invokable ( $ callable , Invokable :... | Resolve if callable is closure or function |
17,995 | public function replaceMissingAttributes ( ) { $ persistedAttributes = array ( ) ; foreach ( $ this -> getValueSet ( ) -> getValues ( ) as $ value ) { $ persistedAttributes [ ] = $ value -> getAttribute ( ) ; } $ newValues = array ( ) ; $ missingAttributes = array_diff ( $ this -> getValueSet ( ) -> getAttributes ( ) -... | Creates fake values for non - persisted attributes |
17,996 | public function getDirectoryParts ( ) : array { return $ this -> myAboveBaseLevel === 0 ? $ this -> myDirectoryParts : array_merge ( array_fill ( 0 , $ this -> myAboveBaseLevel , '..' ) , $ this -> myDirectoryParts ) ; } | Returns the directory parts . |
17,997 | private function myToString ( string $ directorySeparator , ? callable $ stringEncoder = null ) : string { return $ this -> myDirectoryToString ( $ directorySeparator , $ stringEncoder ) . $ this -> myFilenameToString ( $ stringEncoder ) ; } | Returns the path as a string . |
17,998 | private function myDirectoryToString ( string $ directorySeparator , ? callable $ stringEncoder = null ) : string { $ result = '' ; if ( $ this -> myAboveBaseLevel > 0 ) { $ result .= str_repeat ( '..' . $ directorySeparator , $ this -> myAboveBaseLevel ) ; } if ( $ this -> myIsAbsolute ) { $ result .= $ directorySepar... | Returns the directory as a string . |
17,999 | private function myFilenameToString ( ? callable $ stringEncoder = null ) : string { if ( $ this -> myFilename === null ) { return '' ; } if ( $ stringEncoder !== null ) { return $ stringEncoder ( $ this -> myFilename ) ; } return $ this -> myFilename ; } | Returns the filename as a string . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.