idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
13,300 | public function loadWithDefault ( string $ configPath , string $ defaultConfigPath ) : void { if ( ! file_exists ( $ configPath ) ) { return ; } $ configDefault = include $ defaultConfigPath ; $ config = include $ configPath ; if ( ! is_array ( $ configDefault ) && ! is_array ( $ config ) ) { return ; } $ this -> loadA... | Loads configuration from configuration file and from default configuration file . |
13,301 | public function loadArray ( array $ config , $ overwrite = false ) : void { foreach ( $ config as $ name => $ value ) { if ( ! $ overwrite && property_exists ( $ this , $ name ) ) { continue ; } $ this -> $ name = $ value ; } } | Loads configuration from array . |
13,302 | public function loadFromIni ( string $ iniPath , bool $ overwrite = false ) : void { if ( ! file_exists ( $ iniPath ) ) { return ; } $ iniArr = null ; try { $ iniArr = parse_ini_file ( $ iniPath , false , INI_SCANNER_TYPED ) ; } catch ( \ Throwable $ e ) { } if ( ! is_array ( $ iniArr ) ) { return ; } $ iniArr = array_... | Loads configuration from INI file . |
13,303 | protected function fieldsRemain ( ) { $ bufferlen = strlen ( $ this -> buffer ) ; $ minlen = strlen ( $ this -> lastBoundary ) ; if ( $ bufferlen < $ minlen ) { if ( feof ( $ this -> fp ) ) { fclose ( $ this -> fp ) ; throw new \ sndsgd \ http \ data \ DecodeException ( "Invalid multipart data encountered; " . "end of ... | Determine if any more fields remain in the stream |
13,304 | private function getValueFromField ( ) { $ position = $ this -> readUntil ( $ this -> boundary ) ; $ value = substr ( $ this -> buffer , 0 , $ position - 2 ) ; $ this -> buffer = substr ( $ this -> buffer , $ position ) ; return $ value ; } | Get the value of the current field in the input stream |
13,305 | public static function replaceFirst ( $ search , $ replace , $ subject ) { if ( $ search == '' ) { return $ subject ; } $ position = mb_strpos ( $ subject , $ search ) ; if ( $ position !== false ) { return mb_substr ( $ subject , 0 , $ position ) . $ replace . mb_substr ( $ subject , $ position + mb_strlen ( $ search ... | Replace the first occurrence of a given value in the string . |
13,306 | public static function getLevel ( $ level = null ) { $ level = strtoupper ( $ level ) ; if ( array_key_exists ( $ level , self :: $ levels ) ) return self :: $ levels [ $ level ] ; return self :: $ levels [ self :: DEFAULT_LOG_LEVEL ] ; } | Map provided log level to level code |
13,307 | protected function _get ( $ url , $ parameters = null , $ scopes = [ ] , $ class = null ) { $ client = new HttpClient ( $ this -> patrol , 'get' , $ url , $ parameters ) ; $ client -> setScopes ( $ scopes ) ; $ data = $ client -> response ( ) ; if ( isset ( $ data [ 'error' ] ) ) { $ this -> _error ( $ data ) ; } $ dat... | Perform a GET request based on this model |
13,308 | protected function _post ( $ url , $ data = [ ] , $ class = null ) { $ client = new HttpClient ( $ this -> patrol , 'post' , $ url , $ data ) ; $ data = $ client -> response ( ) ; if ( isset ( $ data [ 'error' ] ) ) { $ this -> _error ( $ data ) ; } if ( ! isset ( $ data [ 'data' ] ) ) { return $ data ; } $ data = $ da... | Perform a POST request based on this model |
13,309 | public function redirectToRoute ( $ route , array $ params = [ ] , $ permanent = false ) { $ map = $ this -> app ( ) -> getRouteMap ( ) ; $ url = $ map -> assemble ( $ route , $ params ) ; return $ this -> redirect ( $ url , $ permanent ) ; } | Redirects to a named route . |
13,310 | protected function getHttpClient ( $ config ) { $ guzzleConfig = Arr :: get ( $ config , 'guzzle' , [ ] ) ; return new HttpClient ( Arr :: add ( $ guzzleConfig , 'connect_timeout' , 60 ) ) ; } | Get a fresh Guzzle HTTP client instance . |
13,311 | public function download ( $ request , $ match ) { $ resource = Pluf_Shortcuts_GetObjectOr404 ( 'Tenant_Resource' , $ match [ 'modelId' ] ) ; $ resource -> downloads += 1 ; $ resource -> update ( ) ; return new Pluf_HTTP_Response_File ( $ resource -> getAbsloutPath ( ) , $ resource -> mime_type ) ; } | Download a resource |
13,312 | protected function setValues ( $ data , $ duration ) { $ result = apc_store ( $ data , null , $ duration ) ; return is_array ( $ result ) ? array_keys ( $ result ) : [ ] ; } | Stores multiple key - value pairs in cache . |
13,313 | protected function addValues ( $ data , $ duration ) { $ result = apc_add ( $ data , null , $ duration ) ; return is_array ( $ result ) ? array_keys ( $ result ) : [ ] ; } | Adds multiple key - value pairs to cache . |
13,314 | public function build ( $ type , $ data , $ hypertextRoutes = [ ] ) { if ( ! isset ( $ this -> types [ $ type ] ) ) { throw new \ Exception ( "Unknown response type." ) ; } return new $ this -> types [ $ type ] ( $ data , $ hypertextRoutes ) ; } | Builds the response object . |
13,315 | public function default ( $ key , $ default = null ) { if ( $ this -> has ( $ key ) ) return $ this -> get ( $ key ) ; $ this -> put ( $ key , $ default ) ; return $ default ; } | If key is in the collection return its value . If not insert key with the given default as value and return default . |
13,316 | public function showTables ( ) { $ sql = 'SHOW TABLES' ; $ query = $ this -> pdo -> prepare ( $ sql ) ; $ query -> execute ( ) ; return $ query -> fetchAll ( PDO :: FETCH_ASSOC ) ; } | Run a SHOW TABLES query and return the results |
13,317 | public function getAll ( ) { $ fields = implode ( ', ' , $ this -> fields ) ; $ sql = 'SELECT ' . $ fields . ' FROM ' . $ this -> table ; $ query = $ this -> pdo -> prepare ( $ sql ) ; $ query -> execute ( ) ; return $ query -> fetchAll ( PDO :: FETCH_ASSOC ) ; } | Run a SELECT all query |
13,318 | public function getOneById ( $ id ) { $ id = ( string ) $ id ; $ fields = implode ( ', ' , $ this -> fields ) ; $ sql = 'SELECT ' . $ fields . ' FROM ' . $ this -> table . ' WHERE ' . $ this -> table . '.id = :id' ; $ query = $ this -> pdo -> prepare ( $ sql ) ; $ query -> bindParam ( ':id' , $ id ) ; $ query -> execut... | Run a SELECT query by ID |
13,319 | public function insert ( array $ values ) : int { $ fields = $ this -> fields ; array_shift ( $ fields ) ; $ sql = 'INSERT INTO `' . $ this -> table . '` (' . implode ( ', ' , $ fields ) . ') VALUES (:' . implode ( ', :' , $ fields ) . ')' ; $ query = $ this -> pdo -> prepare ( $ sql ) ; foreach ( $ values as $ key => ... | Insert a new record in the database |
13,320 | public function deleteById ( $ id ) : int { $ sql = 'DELETE FROM `' . $ this -> table . '` WHERE ' ; if ( is_array ( $ id ) ) { $ i = 0 ; foreach ( $ id as $ _id ) { if ( $ i === 0 ) { $ sql .= ' id=:id' . $ i ; } else { $ sql .= ' OR id=:id' . $ i ; } $ i ++ ; } $ query = $ this -> pdo -> prepare ( $ sql ) ; for ( $ j... | Run a DELETE query |
13,321 | public function readFile ( string $ file_name ) { $ reader = new XMLReader ; $ reader -> open ( $ file_name ) ; $ data = $ this -> toArray ( $ reader ) ; $ reader -> close ( ) ; return $ data ; } | Read a XML file into an array |
13,322 | public function readString ( string $ data ) { $ reader = new XMLReader ; $ reader -> XML ( $ data ) ; $ contents = $ this -> toArray ( $ reader ) ; $ reader -> close ( ) ; return $ contents ; } | Read XML Data from a string |
13,323 | public function parseTree ( XMLReader $ reader ) { libxml_use_internal_errors ( true ) ; $ root = new XMLNode ; $ cur = null ; $ read_anything = false ; while ( $ reader -> read ( ) ) { $ read_anything = true ; if ( $ reader -> nodeType === XMLReader :: ELEMENT ) { if ( $ cur === null ) { $ root -> name = $ reader -> n... | Parse the XML into an array . This will add all nodes and attributes to a tree of XML nodes . This is only basic XML flattening for full - blown XML support be sure to use a more fully featured solution like SimpleXML |
13,324 | public function init ( ) { $ this -> setImport ( array ( 'api.models.*' , 'api.components.*' , ) ) ; $ this -> layout = false ; foreach ( Yii :: app ( ) -> log -> routes as $ k => $ v ) { if ( get_class ( $ v ) == 'CWebLogRoute' || get_class ( $ v ) == "CProfileLogRoute" ) Yii :: app ( ) -> log -> routes [ $ k ] -> ena... | Yii Init method Implements basic configuration for module |
13,325 | public function call ( ) { if ( false === $ this -> shouldAuthenticate ( ) ) { $ this -> next -> call ( ) ; return ; } $ this -> checkSecure ( ) ; $ freePass = $ this -> hasFreePass ( ) ; if ( ( false === $ this -> data = $ this -> fetchData ( ) ) && ! $ freePass ) { $ this -> callError ( ) ; return ; } if ( false === ... | Call the middleware |
13,326 | private function checkSecure ( ) { $ environment = $ this -> app -> environment ; $ scheme = $ environment [ "slim.url_scheme" ] ; if ( "https" !== $ scheme && true === $ this -> options [ "secure" ] ) { if ( ! in_array ( $ environment [ "SERVER_NAME" ] , $ this -> options [ "relaxed" ] ) ) { $ message = sprintf ( "Ins... | HTTP allowed only if secure is false or server is in relaxed array . |
13,327 | private function hydrate ( $ data = array ( ) ) { foreach ( $ data as $ key => $ value ) { $ method = "set" . ucfirst ( $ key ) ; if ( method_exists ( $ this , $ method ) ) { call_user_func ( array ( $ this , $ method ) , $ value ) ; } } } | Hydate options from given array |
13,328 | public function callError ( ) { if ( ! ( $ this -> error instanceof Error ) ) { $ this -> error = new Error ( ) ; } $ status = $ this -> error -> getStatus ( ) ; $ this -> app -> response -> status ( $ status ) ; if ( is_callable ( $ this -> options [ "error" ] ) ) { $ this -> options [ "error" ] ( $ this -> error ) ; ... | Call the error handler if it exists |
13,329 | public function setRules ( array $ rules ) { unset ( $ this -> rules ) ; $ this -> rules = new \ SplStack ; foreach ( $ rules as $ callable ) { $ this -> addRule ( $ callable ) ; } return $ this ; } | Set all rules in the stack |
13,330 | public function add ( string $ key , $ value , bool $ override = false ) { if ( ! $ override && $ this -> exists ( $ key ) ) { return ; } $ this -> parameters [ $ key ] = $ value ; } | Add a parameter to the bag |
13,331 | public function start ( ) { $ modules = ModuleModel :: where ( 'module_status' , 1 ) -> get ( ) ; foreach ( $ modules as $ module ) { $ path = $ this -> getModuleDirectory ( $ module -> module_name ) ; if ( $ path ) { $ name = $ module -> module_name ; $ this -> modules [ $ name ] = new Module ( $ this -> app , $ modul... | Get all module from database and initialize |
13,332 | public function register ( ) { foreach ( $ this -> modules as $ module ) { $ module -> register ( ) ; } $ modules = ModuleModel :: where ( 'module_status' , 1 ) -> get ( ) ; foreach ( $ modules as $ module ) { if ( $ module -> module_is_installed ) { $ this -> app [ 'events' ] -> fire ( 'modules.install.' . $ module ->... | Register modules with Moduel class |
13,333 | public function enable ( $ moduleName ) { $ module = $ this -> findOrFalse ( 'module_name' , $ moduleName ) ; if ( $ module ) { if ( ! $ module -> module_status ) { $ module -> module_status = 1 ; $ module -> module_is_enabled = 1 ; $ module -> save ( ) ; return true ; } return false ; } return false ; } | Enable module to load |
13,334 | protected function getListModules ( $ modulesModel ) { $ modules = array ( ) ; foreach ( $ modulesModel as $ module ) { $ modules [ $ module -> module_name ] [ 'name' ] = $ this -> def ( $ module -> module_name , 'name' ) ; $ modules [ $ module -> module_name ] [ 'icon' ] = $ this -> getConfig ( 'assets' ) . '/' . $ mo... | Get list modules |
13,335 | public function buildAssets ( $ moduleName ) { $ module = $ this -> getModuleDirectory ( $ moduleName ) ; if ( $ module ) { $ module .= '/assets' ; if ( $ this -> files -> exists ( $ module ) ) { if ( ! @ $ this -> files -> copyDirectory ( $ module , $ this -> getAssetDirectory ( $ moduleName ) ) ) { $ this -> errors -... | Move contents assets module to public directory |
13,336 | public function removeAssets ( $ moduleName ) { $ assets = $ this -> getAssetDirectory ( $ moduleName ) ; $ this -> files -> deleteDirectory ( $ assets ) ; if ( $ this -> files -> exists ( $ assets ) ) { $ this -> errors -> add ( 'delete_assets' , 'Unable to delete assets in: ' . $ assets ) ; return false ; } return tr... | Remove assets of a module |
13,337 | protected function removeModuleDirectory ( $ moduleName ) { $ this -> files -> deleteDirectory ( $ this -> getModuleDirectory ( $ moduleName ) ) ; if ( $ this -> files -> exists ( $ this -> getModuleDirectory ( $ moduleName ) ) ) { $ this -> errors -> add ( 'delete_files' , 'Unable to delete ' . $ this -> getModuleDire... | Remove module directory |
13,338 | protected function sysVersionDependency ( $ version ) { $ sysVersion = new Version ( $ this -> sysMajorVersion . '.' . $ this -> sysMinorVersion . '.' . $ this -> sysPathVersion ) ; $ needVersion = new Version ( $ version ) ; if ( ! $ sysVersion -> isPartOf ( $ needVersion ) ) { $ this -> errors -> add ( 'module_depend... | Check system dependency |
13,339 | protected function checkDependency ( $ dependencies = null ) { $ errors = array ( ) ; if ( is_null ( $ dependencies ) ) $ dependencies = array ( ) ; $ i = 0 ; $ clean = true ; foreach ( $ dependencies as $ module => $ version ) { if ( $ module == $ this -> systemName ) { if ( ! $ this -> sysVersionDependency ( $ versio... | Check module dependencies |
13,340 | public function uninstall ( $ moduleName ) { $ module = $ this -> findOrFalse ( 'module_name' , $ moduleName ) ; if ( $ module ) { $ version = $ this -> def ( $ moduleName , 'version' ) ; if ( $ this -> checkModuleDepends ( $ moduleName , new Version ( $ version ) ) ) return false ; $ this -> app [ 'events' ] -> fire (... | Uninstall module and remove assets |
13,341 | public function install ( $ tempPath , $ moduleName ) { $ moduleDependency = $ this -> def ( $ tempPath , 'require' , true ) ; if ( ! $ moduleDependency = $ this -> checkDependency ( $ moduleDependency ) ) return false ; if ( ! $ this -> files -> copyDirectory ( $ tempPath , $ this -> path . '/' . $ moduleName ) ) { $ ... | Install module and build assets |
13,342 | protected function updateRegisteredModule ( $ moduleName ) { $ module = $ this -> findOrFalse ( 'module_name' , $ moduleName ) ; $ module -> module_version = $ this -> def ( $ moduleName , 'version' ) ; $ module -> module_is_updated = 1 ; $ module -> save ( ) ; } | Update metadate of module updated |
13,343 | public function zipInit ( $ archive , $ callback = null ) { $ tempPath = $ this -> getAssetDirectory ( ) . '/#tmp/' . uniqid ( ) ; $ result = $ this -> traceZip ( $ archive , $ tempPath ) ; $ this -> files -> deleteDirectory ( $ tempPath ) ; if ( ! is_null ( $ callback ) ) call_user_func ( $ callback , $ result [ 0 ] ,... | Initialize zip module |
13,344 | protected function traceZip ( $ archive , $ tempPath ) { if ( ! $ archive = $ this -> extractZip ( $ archive , $ tempPath , true ) ) return array ( false , null ) ; if ( ! $ this -> checkRequires ( $ tempPath ) ) return array ( false , null ) ; $ moduleName = $ this -> def ( $ tempPath , 'name' , true ) ; if ( $ this -... | Step by Step to install or update a module zip |
13,345 | protected function checkRequires ( $ modulePath ) { $ requires = $ this -> getConfig ( 'requires' , array ( ) ) ; foreach ( $ requires as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( ! $ this -> files -> exists ( $ modulePath . '/' . $ key ) ) { $ this -> errors -> add ( $ this -> configFile , $ this -> conf... | Check module has required file |
13,346 | public function checkModuleDepends ( $ moduleName , Version $ curVersion , Version $ newVersion = null ) { $ modules = $ this -> getListAllModules ( ) ; $ clean = true ; $ i = 0 ; foreach ( $ modules as $ module ) { $ depends = $ this -> def ( $ module [ 'name' ] , 'require' , false , array ( ) ) ; if ( ! is_array ( $ ... | Check others modules depends to this module or not when update or delete module |
13,347 | protected function extractZip ( $ archive , $ target , $ deleteSource = false ) { if ( ! $ this -> files -> exists ( $ target ) ) { $ this -> files -> makeDirectory ( $ target , 0777 , true ) ; } $ archive = new Pclzip ( $ archive ) ; if ( $ archive -> extract ( PCLZIP_OPT_PATH , $ target ) == 0 ) { $ this -> errors ->... | Extract zip file |
13,348 | public function moduleExists ( $ moduleName , $ returnId = false ) { $ module = $ this -> findOrFalse ( 'module_name' , $ moduleName ) ; if ( $ module ) { if ( $ returnId ) return $ module -> module_id ; else return true ; } return false ; } | Check if module exists |
13,349 | public function findOrFalse ( $ field , $ name ) { $ module = ModuleModel :: where ( $ field , $ name ) -> first ( ) ; return ! is_null ( $ module ) ? $ module : false ; } | Find one record from model |
13,350 | public function getModuleDirectory ( $ moduleName ) { if ( $ this -> files -> exists ( $ this -> path . '/' . $ moduleName ) ) return $ this -> path . '/' . $ moduleName ; else return false ; } | Get path of specific module |
13,351 | public function getAssetDirectory ( $ moduleName = null ) { if ( $ moduleName ) return public_path ( ) . '/' . $ this -> getConfig ( 'assets' ) . '/' . $ moduleName ; return public_path ( ) . '/' . $ this -> getConfig ( 'assets' ) . '/' ; } | Get assets path of speciic module |
13,352 | public function make ( ) { return new Request ( $ this -> method , $ this -> target , $ this -> server , $ this -> cookies , $ this -> data , $ this -> files , $ this -> queries , $ this -> attributes , $ this -> uri , $ this -> headers , $ this -> stream , $ this -> version ) ; } | Creates the request instance . |
13,353 | protected function flush ( $ message ) { switch ( $ this -> output ) { case self :: PRINT_AS_OUTPUT : IO :: out ( $ message ) ; break ; case self :: PRINT_AS_MESSAGE : IO :: err ( $ message ) ; break ; } } | Print message to STDOUT or STDERR |
13,354 | public function setOrderBy ( $ field , $ direction = null ) { if ( empty ( $ field ) ) return $ this ; if ( count ( $ order = explode ( ' ' , $ field ) ) == 2 ) { $ field = $ order [ 0 ] ; $ direction = $ order [ 1 ] ; } $ this -> orderBy [ $ field ] = empty ( $ direction ) ? 'ASC' : $ direction ; return $ this ; } | Sets the specified orderBy |
13,355 | public function getOrderBy ( $ field ) { return array_key_exists ( $ field , $ this -> orderBy ) ? $ this -> orderBy [ $ field ] : null ; } | Returns the OrderBy direction for the field specified |
13,356 | public function setOffset ( $ offset ) { if ( $ offset >= PHP_INT_MAX ) { $ offset = false ; } $ this -> offset = $ offset ; return $ this ; } | Sets the offset |
13,357 | public function getResultsAsObjects ( $ classname ) { $ new = array ( ) ; foreach ( ( array ) $ this -> results as $ result ) { if ( is_array ( $ result ) ) $ new [ ] = new $ classname ( $ result ) ; else $ new [ ] = $ result ; } return $ new ; } | Returns all the results as objects of the class specified |
13,358 | public function getResultsAsArray ( ) { $ new = array ( ) ; foreach ( ( array ) $ this -> results as $ result ) { if ( $ result instanceof Object ) $ new [ ] = $ result -> toArray ( ) ; else if ( is_array ( $ result ) ) return $ this -> results ; else throw new Exception ( 'Cannot convert to array: ' . ClassUtils :: ge... | Returns all results as an array |
13,359 | public function getColumnOfResults ( $ col ) { $ new = array ( ) ; foreach ( ( array ) $ this -> results as $ result ) { if ( $ result instanceof Object ) $ new [ ] = $ result -> $ col ; else if ( is_array ( $ result ) ) $ new [ ] = $ result [ $ col ] ; } return $ new ; } | Returns an array containing the value stored in the column specifed for each result |
13,360 | public function isRetrieveAsObjects ( $ val = null ) { if ( ! is_null ( $ val ) ) { $ this -> retrieveAsObjects = $ val ; return $ this ; } return $ this -> retrieveAsObjects == true ; } | Determines if the DTO will retrieve the results as objects . Also acts as a setter for retrieve as objects |
13,361 | public function isRetrieveTotalRecords ( $ val = null ) { if ( ! is_null ( $ val ) ) { $ this -> retrieveTotalRecords = $ val ; return $ this ; } return $ this -> retrieveTotalRecords ; } | Determines if the DTO will retrieve a count of total records for the results Also acts as a setter for retrieve total records |
13,362 | protected function extractAuthParameters ( $ pattern , $ channel , $ callback ) { $ callbackParameters = ( new ReflectionFunction ( $ callback ) ) -> getParameters ( ) ; return collect ( $ this -> extractChannelKeys ( $ pattern , $ channel ) ) -> reject ( function ( $ value , $ key ) { return is_numeric ( $ key ) ; } )... | Extract the parameters from the given pattern and channel . |
13,363 | public function bootPermissions ( ) { foreach ( $ this -> permissions as $ token => $ permission ) { $ this -> permissions [ $ token ] = sprintf ( $ permission , Str :: kebab ( $ this -> getManager ( ) -> getName ( ) ) , Str :: kebab ( $ this -> getName ( ) ) ) ; } } | Boot permissions . |
13,364 | public function newException ( string $ code , $ value ) : Exception { $ exception = $ this -> getException ( $ code ) ; return new $ exception ( strtoupper ( Str :: kebab ( $ this -> getManager ( ) -> getName ( ) ) ) , strtoupper ( Str :: kebab ( $ this -> getName ( ) ) ) , $ value ) ; } | Create a new instance of exception . |
13,365 | private function createRootFolders ( OutputInterface $ output ) { $ em = $ this -> container -> get ( 'doctrine.orm.default_entity_manager' ) ; $ repository = $ this -> container -> get ( 'ekyna_media.folder.repository' ) ; $ name = FolderInterface :: ROOT ; $ output -> write ( sprintf ( '- <comment>%s</comment> %s ' ,... | Creates root folders . |
13,366 | public function addVariety ( \ Librinfo \ VarietiesBundle \ Entity \ Variety $ variety ) { $ this -> varieties [ ] = $ variety ; return $ this ; } | Add variety . |
13,367 | public function removeVariety ( \ Librinfo \ VarietiesBundle \ Entity \ Variety $ variety ) { return $ this -> varieties -> removeElement ( $ variety ) ; } | Remove variety . |
13,368 | public function addSpecies ( \ Librinfo \ VarietiesBundle \ Entity \ Species $ species ) { $ this -> species [ ] = $ species ; return $ this ; } | Add species . |
13,369 | function synchronize ( ) { $ tCounter = 0 ; if ( $ this -> changed ) { $ tFile = fopen ( $ this -> fileName , 'a' ) ; while ( ! flock ( $ tFile , LOCK_EX ) ) { usleep ( 5 ) ; $ tCounter ++ ; if ( $ tCounter == 100 ) { return false ; } } $ tContent = serialize ( $ this -> elements ) ; ftruncate ( $ tFile , 0 ) ; if ( $ ... | Synchronize cache with file |
13,370 | function check ( CacheKey $ key ) { if ( isset ( $ this -> elements [ $ key -> getModule ( ) ] [ $ key -> getProperty ( ) ] ) ) { return true ; } else { return false ; } } | Check is cache entry is set |
13,371 | public function get ( CacheKey $ key ) { if ( ! empty ( $ this -> elements [ $ key -> getModule ( ) ] [ $ key -> getProperty ( ) ] ) ) { $ tValue = $ this -> elements [ $ key -> getModule ( ) ] [ $ key -> getProperty ( ) ] -> getValue ( ) ; return $ tValue ; } else { return false ; } } | Get value from cache or null when not set |
13,372 | public function clear ( CacheKey $ key ) { if ( isset ( $ this -> elements [ $ key -> getModule ( ) ] [ $ key -> getProperty ( ) ] ) ) { unset ( $ this -> elements [ $ key -> getModule ( ) ] [ $ key -> getProperty ( ) ] ) ; $ this -> changed = true ; } } | Unset cache value |
13,373 | function clearModule ( CacheKey $ key ) { if ( isset ( $ this -> elements [ $ key -> getModule ( ) ] ) ) { unset ( $ this -> elements [ $ key -> getModule ( ) ] ) ; $ this -> changed = true ; } } | Clear whole module and all it s properties |
13,374 | public function process ( $ data ) { $ featuredImageProcessing = [ ] ; $ useFeaturedImageUrl = $ this -> isFieldValueBlank ( $ data [ 'featured_image_url' ] ) ; if ( ( $ useFeaturedImageUrl ) && ( $ this -> validateFeaturedImageUrl ( $ data [ 'featured_image_url' ] ) != "passed" ) ) { $ featuredImageProcessing [ 'valid... | Main featured image processing |
13,375 | public function validateFeaturedImageUpload ( $ featuredImageUpload ) { if ( ! $ this -> isImageFileExtensionKosher ( $ featuredImageUpload ) ) { return "Your uploaded image file, " . $ featuredImageUpload . ", is not an accepted image file type." ; } if ( $ this -> doesImageFileExistOnServer ( $ featuredImageUpload )... | Validate the featured_image_upload field s data |
13,376 | public function validateFeaturedImageServer ( $ featuredImageServer ) { if ( ( ! $ featuredImageServer ) || ( $ featuredImageServer == "" ) ) { return "passed" ; } if ( ! $ this -> isImageFileExtensionKosher ( $ featuredImageServer ) ) { return "The image file you selected on your server, " . $ featuredImageServer . ",... | Validate the featured_image_server field s data |
13,377 | public function isImageFileExtensionKosher ( $ filename ) { $ imageFileExtension = $ this -> ImagesHelper -> filenameWithExtensionOnly ( $ filename ) ; $ haystack = Config :: get ( 'lasallecmsfrontend.acceptable_image_extensions_for_uploading' ) ; if ( in_array ( strtolower ( $ imageFileExtension ) , $ haystack ) ) { r... | Is the image s extension allowed? |
13,378 | public function doesImageFileExistOnServer ( $ filename ) { if ( \ File :: exists ( $ this -> ImagesHelper -> pathOfImagesUploadParentFolder ( ) . "/" . Config :: get ( 'lasallecmsfrontend.images_folder_uploaded' ) . '/' . $ filename ) ) { return true ; } return false ; } | Does the iamge file exist already on the server? |
13,379 | public function moveFile ( $ filename ) { $ destinationPath = $ this -> ImagesHelper -> pathOfImagesUploadParentFolder ( ) . "/" . Config :: get ( 'lasallecmsfrontend.images_folder_uploaded' ) ; \ Input :: file ( 'featured_image_upload' ) -> move ( $ destinationPath , $ filename ) ; } | Move the uploaded file from the tmp folder to its proper destination folder |
13,380 | public function where ( $ table , $ column , $ keyword ) { $ connection = Connection :: connect ( ) ; $ selectValue = $ connection -> prepare ( 'select * from ' . $ table . ' where ' . $ column . ' = \'' . $ keyword . '\'' ) ; $ selectValue -> execute ( ) ; return $ selectValue -> fetch ( PDO :: FETCH_ASSOC ) ; } | Return details where a column is matched by the given keyword |
13,381 | protected static function selectAll ( $ model , $ tableName ) { $ connection = Connection :: connect ( ) ; $ getAll = $ connection -> prepare ( 'select * from ' . $ tableName ) ; $ getAll -> execute ( ) ; while ( $ allRows = $ getAll -> fetch ( PDO :: FETCH_ASSOC ) ) { array_push ( $ model -> resultRows , $ allRows ) ;... | Search database for all rows |
13,382 | protected static function selectOne ( $ model , $ tableName , $ id ) { $ connection = Connection :: connect ( ) ; $ getAll = $ connection -> prepare ( 'select * from ' . $ tableName . ' where id=' . $ id ) ; $ getAll -> execute ( ) ; $ row = $ getAll -> fetch ( PDO :: FETCH_ASSOC ) ; array_push ( $ model -> resultRows ... | Search database for one row |
13,383 | protected function updateRow ( ) { $ tableName = $ this -> getTableName ( $ this -> className ) ; $ assignedValues = $ this -> getAssignedValues ( ) ; $ updateDetails = [ ] ; for ( $ i = 0 ; $ i < count ( $ assignedValues [ 'columns' ] ) ; $ i ++ ) { array_push ( $ updateDetails , $ assignedValues [ 'columns' ] [ $ i ]... | Edit an existing row |
13,384 | public static function destroy ( $ id ) { if ( self :: confirmIdExists ( $ id ) ) { return self :: doDelete ( $ id ) ; } else { throw new Exception ( 'Now rows found with ID ' . $ id . ' in the database, it may have been already deleted' ) ; } } | Call doDelete function if the specified id exists |
13,385 | protected static function doDelete ( $ id ) { $ model = self :: createModelInstance ( ) ; $ tableName = $ model -> getTableName ( $ model -> className ) ; $ connection = Connection :: connect ( ) ; $ delete = $ connection -> prepare ( 'delete from ' . $ tableName . ' where id =' . $ id ) ; return $ delete -> execute ( ... | Delete an existing row from the database |
13,386 | public function generate ( $ actionManager ) { if ( $ actionManager instanceof ActionManagerInterface ) { $ this -> actionManager = $ actionManager ; $ this -> actionManagerClass = get_class ( $ this -> actionManager ) ; } if ( is_string ( $ actionManager ) && class_exists ( $ actionManager ) ) { $ this -> actionManage... | Generates the ActionManager object |
13,387 | public static function load ( $ file ) { if ( file_exists ( $ file ) ) { $ env = \ M1 \ Env \ Parser :: parse ( file_get_contents ( $ file ) ) ; foreach ( $ env as $ key => $ value ) { putenv ( "{$key}={$value}" ) ; } } } | Load file containing environment variables and setup environment with these variables |
13,388 | function addForeignKey ( $ table , $ pkname , $ tables ) { if ( is_string ( $ tables ) ) $ tables = array ( $ tables ) ; $ this -> _foreignKeys [ $ table ] = array ( 'primaryKey' => $ pkname , 'tables' => $ tables ) ; } | Add some config data for a new foreign key |
13,389 | function pdo_query_select ( $ query , $ values = NULL ) { if ( ! is_null ( $ values ) && ! is_array ( $ values ) ) $ values = array ( $ values ) ; $ st = $ this -> prepare ( $ query ) ; $ st -> execute ( $ values ) ; return $ st ; } | Helper query method for a SQL SELECT request |
13,390 | public function paginate ( ) { $ this -> total = $ this -> dataSource -> getTotal ( $ this -> source ) ; if ( ( $ this -> getPagesCount ( ) > 0 && $ this -> getPage ( ) > $ this -> getPagesCount ( ) ) || $ this -> getPage ( ) <= 0 ) { $ this -> handler -> wrongPageCallback ( ) ; } $ this -> data = $ this -> dataSource ... | Apply limits to source . |
13,391 | public function initialize ( $ routepath ) { $ this -> routepath = $ routepath ; Template :: addPath ( __DIR__ . '/templates/' , 'CatLab/Accounts/' ) ; Text :: getInstance ( ) -> addPath ( 'catlab.accounts' , __DIR__ . '/locales/' ) ; Application :: getInstance ( ) -> on ( 'dispatch:before' , array ( $ this , 'setReque... | Set template paths config vars etc |
13,392 | public function setRequestUser ( Request $ request ) { $ request -> addUserCallback ( 'accounts' , function ( Request $ request ) { $ userid = $ request -> getSession ( ) -> get ( 'catlab-user-id' ) ; if ( $ userid ) { $ user = MapperFactory :: getUserMapper ( ) -> getFromId ( $ userid ) ; if ( $ user ) return $ user ;... | Set user from session |
13,393 | public function login ( Request $ request , User $ user , $ registration = false ) { if ( $ this -> requiresEmailValidation ( ) ) { if ( ! $ user -> isEmailVerified ( ) ) { $ request -> getSession ( ) -> set ( 'catlab-non-verified-user-id' , $ user -> getId ( ) ) ; return Response :: redirect ( URLBuilder :: getURL ( $... | Login a specific user |
13,394 | public function postLogin ( Request $ request , \ Neuron \ Interfaces \ Models \ User $ user , $ registered = false ) { $ parameters = array ( ) ; if ( $ registered ) { $ parameters [ 'registered' ] = 1 ; } $ request -> getSession ( ) -> set ( 'userJustRegistered' , $ registered ) ; $ this -> trigger ( 'user:login' , [... | Called right after a user is logged in . Should be a redirect . |
13,395 | public function postLogout ( Request $ request ) { if ( $ redirect = $ request -> getSession ( ) -> get ( 'post-login-redirect' ) ) { $ request -> getSession ( ) -> set ( 'post-login-redirect' , null ) ; $ request -> getSession ( ) -> set ( 'cancel-login-redirect' , null ) ; return Response :: redirect ( $ redirect ) ;... | Called after a redirect |
13,396 | public function setRoutes ( Router $ router ) { $ router -> addFilter ( 'authenticated' , array ( $ this , 'routerVerifier' ) ) ; $ router -> match ( 'GET|POST' , $ this -> routepath . '/login/{authenticator}' , '\CatLab\Accounts\Controllers\LoginController@authenticator' ) ; $ router -> match ( 'GET' , $ this -> route... | Register the routes required for this module . |
13,397 | public static function asciiRand ( $ length , $ subset = self :: ASCII_ALL ) { switch ( $ subset ) { case self :: ASCII_ALPHANUM : $ subset = self :: $ asciiAlphanum ; break ; case self :: ASCII_NONALPHANUM : $ subset = self :: $ asciNonAlphanum ; break ; default : $ subset = array_merge ( self :: $ asciiAlphanum , sel... | Generates a string of random ASCII characters |
13,398 | public static function getUniqid ( $ hash = 'sha256' , $ prefix = '' , $ entropy = 10000 , $ rawOutput = false ) { $ str = mt_rand ( ~ PHP_INT_MAX , PHP_INT_MAX ) . json_encode ( [ $ _COOKIE , $ _REQUEST , $ _FILES , $ _ENV , $ _GET , $ _POST , $ _SERVER ] ) . uniqid ( $ prefix , true ) . self :: asciiRand ( $ entropy ... | Generates a unique identifier |
13,399 | public static function getFingerprint ( $ hashAlgo = 'sha256' ) { return hash ( $ hashAlgo , '#QramRAN7*s%6n%@x*53jVVPsnrz@5MY$49o^mhJ8HqY%3a09yJnSWg9lBl$O4CKUb&&S%EgYBjhUZEbhquw$keCjR6I%zMcA!Qr' . self :: get ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) . 'OE2%fWaZh4jfZPiNXKmHfUw6ok6Z0s#PInaFa8&o#xh#nVyaFaXHPUcv^2y579PnYr5AOs6... | Returns a hashed browser fingerprint |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.