idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
22,000 | protected function rewriteRoutingSetUpCurrentRouteByRequest ( ) { $ request = & $ this -> request ; $ toolClass = self :: $ toolClass ; $ this -> currentRoute -> SetController ( str_replace ( [ '/' , '\\\\' ] , [ '\\' , '//' ] , $ toolClass :: GetPascalCaseFromDashed ( $ request -> GetControllerName ( ) ) ) ) -> SetAction ( $ toolClass :: GetPascalCaseFromDashed ( $ request -> GetActionName ( ) ) ) ; } | Set up into current route controller and action in pascal case from request object . |
22,001 | public function time ( string $ name , string $ message = null ) : TimerContract { $ id = isset ( $ this -> timers [ $ name ] ) ? \ uniqid ( $ name ) : $ name ; $ this -> timers [ $ id ] = $ this -> createTimer ( $ name , \ microtime ( true ) , $ message ) ; return $ this -> timers [ $ id ] ; } | Time a process . |
22,002 | public function timeEnd ( $ name = null ) : void { $ timer = $ name instanceof TimerContract ? $ name : $ this -> resolveTimerFromName ( $ name ) ; $ timer -> end ( ) ; } | Calculate timed taken for a process to complete . |
22,003 | protected function resolveTimerFromName ( string $ name = null ) : TimerContract { $ id = \ is_null ( $ name ) ? \ uniqid ( ) : $ name ; if ( isset ( $ this -> timers [ $ id ] ) ) { return $ this -> timers [ $ id ] ; } return $ this -> createTimer ( $ name , constant ( 'LARAVEL_START' ) ) ; } | Resolve timer from name . |
22,004 | protected function createTimer ( string $ name , $ startedAt , string $ message = null ) : TimerContract { return ( new Timer ( $ name , $ startedAt , $ message ) ) -> setLogger ( $ this -> getLogger ( ) ) ; } | Create a new timer . |
22,005 | public function HasHeader ( $ name = '' ) { if ( $ this -> headers === NULL ) $ this -> initHeaders ( ) ; return isset ( $ this -> headers [ $ name ] ) ; } | Return if request has any http header by given name . |
22,006 | public function & SetParam ( $ name = '' , $ value = '' ) { if ( $ this -> params === NULL ) $ this -> initParams ( ) ; $ this -> params [ $ name ] = $ value ; return $ this ; } | Set directly raw parameter value without any conversion . |
22,007 | public function & RemoveParam ( $ name = '' ) { if ( $ this -> params === NULL ) $ this -> initParams ( ) ; unset ( $ this -> params [ $ name ] ) ; return $ this ; } | Remove parameter by name . |
22,008 | public function addDevelopmentAsset ( $ value , $ fingerprint = null , $ group = null ) { if ( $ value instanceof Asset ) { $ group = $ value -> getGroup ( ) ; $ fingerprint = $ value -> getBuildPath ( ) ; $ value = $ value -> getRelativePath ( ) ; } $ this -> development [ $ group ] [ $ value ] = $ fingerprint ; } | Add a development asset . |
22,009 | public function getDevelopmentAsset ( $ value , $ group = null ) { if ( $ value instanceof Asset ) { $ group = $ value -> getGroup ( ) ; $ value = $ value -> getRelativePath ( ) ; } return isset ( $ this -> development [ $ group ] [ $ value ] ) ? $ this -> development [ $ group ] [ $ value ] : null ; } | Get a development assets build path . |
22,010 | public function getDevelopmentAssets ( $ group = null ) { return is_null ( $ group ) ? $ this -> development : $ this -> development [ $ group ] ; } | Get all or a subset of development assets . |
22,011 | public function hasDevelopmentAssets ( $ group = null ) { return is_null ( $ group ) ? ! empty ( $ this -> development ) : ! empty ( $ this -> development [ $ group ] ) ; } | Determine if the entry has any development assets . |
22,012 | public function resetDevelopmentAssets ( $ group = null ) { if ( is_null ( $ group ) ) { $ this -> development = array ( ) ; } else { $ this -> development [ $ group ] = array ( ) ; } } | Reset the development assets . |
22,013 | public function getProductionFingerprint ( $ group ) { return isset ( $ this -> fingerprints [ $ group ] ) ? $ this -> fingerprints [ $ group ] : null ; } | Get the entry fingerprint . |
22,014 | public function findMissingConstructorArgs ( ) { try { $ class = new ReflectionClass ( $ this -> getClassName ( ) ) ; } catch ( ReflectionException $ e ) { return $ this ; } if ( $ constructor = $ class -> getConstructor ( ) ) { $ finder = $ this -> getExecutableFinder ( ) ; foreach ( $ constructor -> getParameters ( ) as $ key => $ parameter ) { if ( $ this -> hasArgumentAtPosition ( $ key ) ) { continue ; } $ snakeParameter = $ this -> normalizeConstructorParameter ( $ parameter -> name ) ; list ( $ name , $ suffix ) = explode ( '_' , $ snakeParameter ) ; if ( in_array ( $ suffix , $ this -> validSuffixes ) ) { $ path = $ this -> getEnvironmentVariable ( $ snakeParameter ) ? : $ finder -> find ( $ name ) ; if ( $ path ) { $ this -> setArgument ( $ path , $ key ) ; } else { $ this -> log -> error ( sprintf ( 'Failed to find required constructor argument for filter "%s". (%s)' , $ this -> filter , $ parameter ) ) ; $ this -> ignored = true ; } } elseif ( str_is ( 'nodePaths' , $ parameter -> name ) ) { $ this -> setArgument ( $ this -> nodePaths , $ key ) ; } } } return $ this ; } | Find and set any missing constructor arguments . |
22,015 | public function whenAssetIs ( $ pattern ) { return $ this -> when ( function ( $ asset ) use ( $ pattern ) { return ( bool ) preg_match ( '#' . $ pattern . '#' , $ asset -> getRelativePath ( ) ) ; } ) ; } | Add a asset name pattern requirement to the filter . |
22,016 | public function whenEnvironmentIs ( ) { $ environments = func_get_args ( ) ; $ appEnvironment = $ this -> appEnvironment ; return $ this -> when ( function ( $ asset ) use ( $ environments , $ appEnvironment ) { return in_array ( $ appEnvironment , $ environments ) ; } ) ; } | Add an environment requirement to the filter . |
22,017 | public function setArgument ( $ argument , $ position = null ) { array_splice ( $ this -> arguments , $ position ? : count ( $ this -> arguments ) , 0 , array ( $ argument ) ) ; return $ this ; } | Set a single instantiation argument . |
22,018 | public function getInstance ( ) { if ( ! $ class = $ this -> getClassName ( ) ) { $ this -> log -> error ( sprintf ( '"%s" will not be applied to asset "%s" due to an invalid filter name.' , $ this -> filter , $ this -> resource -> getRelativePath ( ) ) ) ; } if ( $ this -> ignored or is_null ( $ class ) or ! $ this -> processRequirements ( ) ) return ; if ( $ class instanceof FilterInterface ) { $ instance = $ class ; } else { $ reflection = new ReflectionClass ( $ class ) ; if ( ! $ reflection -> getConstructor ( ) ) { $ instance = $ reflection -> newInstance ( ) ; } else { $ instance = $ reflection -> newInstanceArgs ( $ this -> arguments ) ; } } foreach ( $ this -> before as $ callback ) { if ( is_callable ( $ callback ) ) { call_user_func ( $ callback , $ instance ) ; } } return $ instance ; } | Attempt to instantiate the filter if it exists and has not been ignored . |
22,019 | public function processRequirements ( ) { foreach ( $ this -> requirements as $ requirement ) { if ( ! call_user_func ( $ requirement , $ this -> resource , $ this ) ) { return false ; } } return true ; } | Process any requirements on the filter . |
22,020 | public function loadClass ( $ class ) { $ result = $ this -> loadCachedClass ( $ class ) ; if ( $ result === false ) { $ result = parent :: loadClass ( $ class ) ; } if ( $ this -> verbose ) { return $ result !== false ; } } | Loads the class by first checking if the file path is cached . |
22,021 | private function loadCachedClass ( $ class ) { $ result = false ; if ( isset ( $ this -> cache [ $ class ] ) ) { $ result = include $ this -> cache [ $ class ] ; if ( $ result === false ) { unset ( $ this -> cache [ $ class ] ) ; $ this -> saveCache ( ) ; } } return $ result !== false ; } | Attempts loading class from the known class cache . |
22,022 | protected function loadFile ( $ file , $ class ) { parent :: loadFile ( $ file , $ class ) ; $ this -> cache [ $ class ] = $ file ; $ this -> saveCache ( ) ; return true ; } | Loads the class from the given file and stores the path into cache . |
22,023 | public function addCoordinate ( Coordinate $ coordinate ) { $ this -> coordinates [ ] = $ coordinate ; $ this -> setNumber ( count ( $ this -> coordinates ) ) ; return $ this ; } | Add new coordinate |
22,024 | public function setCoordinate ( \ ArrayObject $ coordinates ) { $ this -> coordinates = $ coordinates ; $ this -> setNumber ( count ( $ coordinates ) ) ; return $ this ; } | Add an array of coordinates |
22,025 | public function setNumber ( $ num ) { $ num = ( int ) $ num ; if ( $ num <= 0 ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid Number "%s" - Polygon Coordinates Number Must Be ' . 'Greater Than Zero' , $ num ) ) ; } $ count = count ( $ this -> getCoordinates ( ) ) ; if ( $ num > $ count ) { throw new \ OutOfBoundsException ( sprintf ( 'Given Coodrinates Number "%s" Is Greater Than The Actual ' . 'Coordinates Array Size "%s"' , $ num , $ count ) ) ; } $ this -> count = $ num ; return $ this ; } | Set Polygon coordinates number |
22,026 | private function assertPointsArrayLength ( ) { if ( count ( $ this -> getCoordinates ( ) ) < self :: $ MIN_LENGTH ) { throw new \ RuntimeException ( sprintf ( 'There Must Be At Least "%s" Coordinates To Draw A Polygon' , self :: $ MIN_LENGTH ) ) ; } } | Assert Points Array Length |
22,027 | public function likeIt ( $ user = null ) { if ( ! $ this -> isLiked ( ) ) { $ this -> likes ( ) -> create ( [ 'user_id' => $ user ? $ user -> id : auth ( ) -> id ( ) ] ) ; $ this -> incrementCount ( ) ; } } | Like like by authenticated user If any user is given like by that user After liking increments the like Count |
22,028 | public function unLikeIt ( $ user = null ) { if ( $ like = $ this -> isLiked ( $ user ) ) { $ like -> delete ( ) ; $ this -> decrementCount ( ) ; } } | It can unlike a liked Model If user is given unlike likeable model for that user After unlike decrements the like count |
22,029 | public function isLiked ( $ user = null ) { return $ this -> likes ( ) -> where ( [ 'user_id' => $ user ? $ user -> id : auth ( ) -> id ( ) , 'likeable_type' => get_class ( $ this ) , 'likeable_id' => $ this -> id ] ) -> first ( ) ; } | Check if likeable model is liked or not |
22,030 | public function toggleLike ( $ user = null ) { $ this -> isLiked ( $ user ) ? $ this -> unLikeIt ( $ user ) : $ this -> likeIt ( $ user ) ; } | Toggle like of likeable model |
22,031 | public static function byObjectMethod ( $ values , $ method ) { if ( isset ( $ values ) && Inspector :: isTraversable ( $ values ) ) { if ( is_array ( $ values ) ) { $ flat_values = array ( ) ; $ setter = 'setArrayValue' ; } else { $ flat_values = new \ stdClass ( ) ; $ setter = 'setObjectValue' ; } foreach ( $ values as $ key => $ value ) { if ( is_object ( $ value ) && method_exists ( $ value , $ method ) ) { $ flat_value = $ value -> { $ method } ( ) ; static :: $ setter ( $ flat_values , $ key , $ flat_value ) ; } else { static :: $ setter ( $ flat_values , $ key , $ value ) ; } } return $ flat_values ; } return $ values ; } | Create a flattened object by calling a method on all values provided . |
22,032 | public function find ( $ id ) { return Arr :: first ( $ this -> items , function ( $ key , Contract $ skill ) use ( $ id ) { return $ skill -> getId ( ) === $ id ; } , null ) ; } | Find a skill by its ID |
22,033 | public function findByName ( $ name ) { return Arr :: first ( $ this -> items , function ( $ key , Contract $ skill ) use ( $ name ) { return $ skill -> getName ( ) === strtolower ( $ name ) ; } , null ) ; } | Find a skill by its name |
22,034 | public function calcMod10V1 ( string $ number , string $ separator = "" , int $ minimumLength = 6 ) : string { $ revstr = strrev ( ( string ) intval ( $ number ) ) ; $ revstrLen = strlen ( $ revstr ) ; $ total = 0 ; for ( $ i = 0 ; $ i < $ revstrLen ; $ i ++ ) { if ( $ i % 2 == 0 ) { $ multiplier = 2 ; } else { $ multiplier = 1 ; } $ subtotal = intval ( $ revstr [ $ i ] ) * $ multiplier ; if ( $ subtotal >= 10 ) { $ temp = ( string ) $ subtotal ; $ subtotal = intval ( $ temp [ 0 ] ) + intval ( $ temp [ 1 ] ) ; } $ total += $ subtotal ; } $ checkDigit = ( 10 - ( $ total % 10 ) ) % 10 ; $ crn = str_pad ( ltrim ( $ number , "0" ) , $ minimumLength - 1 , "0" , STR_PAD_LEFT ) . $ separator . $ checkDigit ; return $ crn ; } | Calculate Modulus 10 Version 1 . |
22,035 | protected function getCurrentRoute ( ) : string { $ request = resolve ( HttpRequest :: class ) ; $ method = strtoupper ( $ request -> getMethod ( ) ) ; $ path = ltrim ( $ request -> path ( ) , '/' ) ; $ host = $ request -> getHost ( ) ; ! is_null ( $ host ) && $ host = rtrim ( $ host , '/' ) ; return "{$method} {$host}/{$path}" ; } | Get current route . |
22,036 | public function setLevel ( $ level ) { if ( ! ( $ level >= 0.01 && $ level <= 4.99 ) ) { throw new \ InvalidArgumentException ( "Gamma Level Must Be In Range(0.01,4.99)" ) ; } $ this -> level = ( float ) $ level ; return $ this ; } | Set gamma level |
22,037 | protected function createConfigFile ( string $ name ) : void { $ file = base_path ( $ this -> moduleName ( ) . '/' . $ name . '/Config/config.php' ) ; if ( ! $ this -> files -> exists ( $ file ) ) { $ this -> files -> put ( $ file , $ this -> files -> get ( __DIR__ . '/stubs/config.stub' ) ) ; } } | Create module config . |
22,038 | public function getFieldDefinition ( $ arrOverrides = [ ] ) { $ arrFieldDef = parent :: getFieldDefinition ( $ arrOverrides ) ; $ arrFieldDef [ 'inputType' ] = 'text' ; $ arrFieldDef [ 'eval' ] [ 'disabled' ] = true ; return $ arrFieldDef ; } | This generates the field definition for use in a DCA . |
22,039 | public function getDataFor ( $ arrIds ) { $ statement = $ this -> connection -> createQueryBuilder ( ) -> select ( '*' ) -> from ( 'tl_metamodel_rating' ) -> andWhere ( 'mid=:mid AND aid=:aid AND iid IN (:iids)' ) -> setParameter ( 'mid' , $ this -> getMetaModel ( ) -> get ( 'id' ) ) -> setParameter ( 'aid' , $ this -> get ( 'id' ) ) -> setParameter ( 'iids' , $ arrIds , Connection :: PARAM_STR_ARRAY ) -> execute ( ) ; $ arrResult = [ ] ; while ( $ objData = $ statement -> fetch ( \ PDO :: FETCH_OBJ ) ) { $ arrResult [ $ objData -> iid ] = [ 'votecount' => ( int ) $ objData -> votecount , 'meanvalue' => ( float ) $ objData -> meanvalue , ] ; } foreach ( \ array_diff ( $ arrIds , \ array_keys ( $ arrResult ) ) as $ intId ) { $ arrResult [ $ intId ] = [ 'votecount' => 0 , 'meanvalue' => 0 , ] ; } return $ arrResult ; } | This method is called to retrieve the data for certain items from the database . |
22,040 | public function unsetDataFor ( $ arrIds ) { $ this -> connection -> createQueryBuilder ( ) -> delete ( 'tl_metamodel_rating' ) -> andWhere ( 'mid=:mid AND aid=:aid AND iid IN (:iids)' ) -> setParameter ( 'mid' , $ this -> getMetaModel ( ) -> get ( 'id' ) ) -> setParameter ( 'aid' , $ this -> get ( 'id' ) ) -> setParameter ( 'iids' , $ arrIds , Connection :: PARAM_STR_ARRAY ) -> execute ( ) ; } | Delete all votes for the given items . |
22,041 | public function addVote ( $ intItemId , $ fltValue , $ blnLock = false ) { if ( $ this -> getSessionBag ( ) -> get ( $ this -> getLockId ( $ intItemId ) ) ) { return ; } $ arrData = $ this -> getDataFor ( [ $ intItemId ] ) ; if ( ! $ arrData || ! $ arrData [ $ intItemId ] [ 'votecount' ] ) { $ voteCount = 0 ; $ prevPercent = 0 ; } else { $ voteCount = $ arrData [ $ intItemId ] [ 'votecount' ] ; $ prevPercent = ( float ) $ arrData [ $ intItemId ] [ 'meanvalue' ] ; } $ grandTotal = ( $ voteCount * $ this -> get ( 'rating_max' ) * $ prevPercent ) ; $ hundred = ( $ this -> get ( 'rating_max' ) * ( ++ $ voteCount ) ) ; $ value = ( 1 / $ hundred * ( $ grandTotal + $ fltValue ) ) ; $ arrSet = [ 'mid' => $ this -> getMetaModel ( ) -> get ( 'id' ) , 'aid' => $ this -> get ( 'id' ) , 'iid' => $ intItemId , 'votecount' => $ voteCount , 'meanvalue' => $ value , ] ; $ queryBuilder = $ this -> connection -> createQueryBuilder ( ) ; if ( ! $ arrData || ! $ arrData [ $ intItemId ] [ 'votecount' ] ) { $ queryBuilder -> insert ( 'tl_metamodel_rating' ) -> values ( $ arrSet ) ; } else { foreach ( $ arrSet as $ key => $ value ) { $ queryBuilder -> set ( $ key , ':' . $ key ) -> setParameter ( $ key , $ value ) ; } $ queryBuilder -> update ( 'tl_metamodel_rating' ) -> andWhere ( 'mid=:mid AND aid=:aid AND iid=:iid' ) -> setParameter ( 'mid' , $ this -> getMetaModel ( ) -> get ( 'id' ) ) -> setParameter ( 'aid' , $ this -> get ( 'id' ) ) -> setParameter ( 'iid' , $ intItemId ) ; } $ queryBuilder -> execute ( ) ; if ( $ blnLock ) { $ this -> getSessionBag ( ) -> set ( $ this -> getLockId ( $ intItemId ) , true ) ; } } | Add a vote to the database . |
22,042 | protected function ensureImage ( $ uuidImage , $ strDefault ) { $ imagePath = ToolboxFile :: convertValueToPath ( $ uuidImage ) ; if ( \ strlen ( $ imagePath ) && \ file_exists ( TL_ROOT . '/' . $ imagePath ) ) { return $ imagePath ; } return $ strDefault ; } | Test whether the given image exists . |
22,043 | public function prepareTemplate ( Template $ objTemplate , $ arrRowData , $ objSettings ) { parent :: prepareTemplate ( $ objTemplate , $ arrRowData , $ objSettings ) ; $ base = Environment :: get ( 'base' ) ; $ lang = $ this -> getActiveLanguageArray ( ) ; $ strEmpty = $ this -> ensureImage ( $ this -> get ( 'rating_emtpy' ) , 'bundles/metamodelsattributerating/star-empty.png' ) ; $ strFull = $ this -> ensureImage ( $ this -> get ( 'rating_full' ) , 'bundles/metamodelsattributerating/star-full.png' ) ; $ strHover = $ this -> ensureImage ( $ this -> get ( 'rating_hover' ) , 'bundles/metamodelsattributerating/star-hover.png' ) ; if ( \ file_exists ( TL_ROOT . '/' . $ strEmpty ) ) { $ size = \ getimagesize ( TL_ROOT . '/' . $ strEmpty ) ; } else { $ size = \ getimagesize ( TL_ROOT . '/web/' . $ strEmpty ) ; } $ objTemplate -> imageWidth = $ size [ 0 ] ; $ objTemplate -> rateHalf = $ this -> get ( 'rating_half' ) ? 'true' : 'false' ; $ objTemplate -> name = 'rating_attribute_' . $ this -> get ( 'id' ) . '_' . $ arrRowData [ 'id' ] ; $ objTemplate -> ratingDisabled = ( $ this -> scopeDeterminator -> currentScopeIsBackend ( ) || $ objSettings -> get ( 'rating_disabled' ) || $ this -> getSessionBag ( ) -> get ( $ this -> getLockId ( $ arrRowData [ 'id' ] ) ) ) ; $ value = ( $ this -> get ( 'rating_max' ) * ( float ) $ arrRowData [ $ this -> getColName ( ) ] [ 'meanvalue' ] ) ; $ intInc = \ strlen ( $ this -> get ( 'rating_half' ) ) ? .5 : 1 ; $ objTemplate -> currentValue = ( \ round ( ( $ value / $ intInc ) , 0 ) * $ intInc ) ; $ objTemplate -> tipText = \ sprintf ( $ lang [ 'metamodel_rating_label' ] , '[VALUE]' , $ this -> get ( 'rating_max' ) ) ; $ objTemplate -> ajaxUrl = $ this -> router -> generate ( 'metamodels.attribute_rating.rate' ) ; $ objTemplate -> ajaxData = \ json_encode ( [ 'id' => $ this -> get ( 'id' ) , 'pid' => $ this -> get ( 'pid' ) , 'item' => $ arrRowData [ 'id' ] , ] ) ; $ arrOptions = [ ] ; $ intValue = $ intInc ; while ( $ intValue <= $ this -> get ( 'rating_max' ) ) { $ arrOptions [ ] = $ intValue ; $ intValue += $ intInc ; } $ objTemplate -> options = $ arrOptions ; $ objTemplate -> imageEmpty = $ base . $ strEmpty ; $ objTemplate -> imageFull = $ base . $ strFull ; $ objTemplate -> imageHover = $ base . $ strHover ; } | Initialize the template with values . |
22,044 | public function sortIds ( $ idList , $ strDirection ) { $ statement = $ this -> connection -> createQueryBuilder ( ) -> select ( 'iid' ) -> from ( 'tl_metamodel_rating' ) -> andWhere ( 'mid=:mid AND aid=:aid AND iid IN (:iids)' ) -> setParameter ( 'mid' , $ this -> getMetaModel ( ) -> get ( 'id' ) ) -> setParameter ( 'aid' , $ this -> get ( 'id' ) ) -> setParameter ( 'iids' , $ idList , Connection :: PARAM_STR_ARRAY ) -> orderBy ( 'meanvalue' , $ strDirection ) -> execute ( ) ; $ arrSorted = $ statement -> fetchAll ( \ PDO :: FETCH_COLUMN , 'iid' ) ; return ( $ strDirection == 'DESC' ) ? \ array_merge ( $ arrSorted , \ array_diff ( $ idList , $ arrSorted ) ) : \ array_merge ( \ array_diff ( $ idList , $ arrSorted ) , $ arrSorted ) ; } | Sorts the given array list by field value in the given direction . |
22,045 | protected function getSessionBag ( ) { if ( $ this -> scopeDeterminator -> currentScopeIsBackend ( ) ) { return $ this -> session -> getBag ( 'contao_backend' ) ; } if ( $ this -> scopeDeterminator -> currentScopeIsFrontend ( ) ) { return $ this -> session -> getBag ( 'contao_frontend' ) ; } return $ this -> session -> getBag ( 'attributes' ) ; } | Get the session bag depending on current scope . |
22,046 | public function GetMicrotime ( ) { if ( $ this -> microtime === NULL ) $ this -> microtime = $ this -> globalServer [ 'REQUEST_TIME_FLOAT' ] ; return $ this -> microtime ; } | Get timestamp in seconds as float when the request has been started with microsecond precision . |
22,047 | public function & SetTopLevelDomain ( $ topLevelDomain ) { if ( $ this -> domainParts === NULL ) $ this -> initDomainSegments ( ) ; $ this -> domainParts [ 2 ] = $ topLevelDomain ; $ this -> hostName = trim ( implode ( '.' , $ this -> domainParts ) , '.' ) ; if ( $ this -> hostName && $ this -> portDefined ) $ this -> host = $ this -> hostName . ':' . $ this -> port ; $ this -> domainUrl = NULL ; $ this -> baseUrl = NULL ; $ this -> requestUrl = NULL ; $ this -> fullUrl = NULL ; return $ this ; } | Set TOP level domain like com or co . uk . Method also change server name and host record automatically . |
22,048 | public function collection ( string $ identifier , ? Closure $ callback = null ) : Collection { if ( ! isset ( $ this -> collections [ $ identifier ] ) ) { $ directory = $ this -> prepareDefaultDirectory ( ) ; $ this -> collections [ $ identifier ] = new Collection ( $ directory , $ identifier ) ; } if ( is_callable ( $ callback ) ) { call_user_func ( $ callback , $ this -> collections [ $ identifier ] ) ; } return $ this -> collections [ $ identifier ] ; } | Create or return an existing collection . |
22,049 | protected function prepareDefaultDirectory ( ) : Directory { $ path = $ this -> finder -> setWorkingDirectory ( '/' ) ; return new Directory ( $ this -> factory , $ this -> finder , $ path ) ; } | Prepare the default directory for a new collection . |
22,050 | public function package ( string $ package , ? string $ namespace = null ) : void { if ( is_null ( $ namespace ) ) { list ( $ vendor , $ namespace ) = explode ( '/' , $ package ) ; } $ this -> finder -> addNamespace ( $ namespace , $ package ) ; } | Register a package with the environment . |
22,051 | public function collections ( array $ collections ) : void { foreach ( $ collections as $ name => $ callback ) { $ this -> make ( $ name , $ callback ) ; } } | Register an array of collections . |
22,052 | public function offsetGet ( $ offset ) : ? Collection { return $ this -> has ( $ offset ) ? $ this -> collection ( $ offset ) : null ; } | Get a collection offset . |
22,053 | public function make ( $ filter ) { if ( $ filter instanceof Filter ) { return clone $ filter ; } $ filter = isset ( $ this -> aliases [ $ filter ] ) ? $ this -> aliases [ $ filter ] : $ filter ; if ( is_array ( $ filter ) ) { list ( $ filter , $ callback ) = array ( current ( $ filter ) , next ( $ filter ) ) ; } $ filter = new Filter ( $ this -> log , $ filter , $ this -> nodePaths , $ this -> appEnvironment ) ; if ( isset ( $ callback ) and is_callable ( $ callback ) ) { call_user_func ( $ callback , $ filter ) ; } return $ filter ; } | Make a new filter instance . |
22,054 | public function getValues ( ) { while ( $ row = $ this -> getNextRow ( ) ) { if ( $ this -> columnCount ( ) > 1 ) { $ key = rtrim ( reset ( $ row ) ) ; $ val = rtrim ( next ( $ row ) ) ; yield $ key => $ val ; } else { yield rtrim ( reset ( $ row ) ) ; } } } | Get a generator function to fetch from . |
22,055 | public function groupBy ( ... $ keys ) { $ data = [ ] ; while ( $ row = $ this -> getNextRow ( ) ) { $ position = & $ data ; foreach ( $ keys as $ key ) { if ( is_callable ( $ key ) ) { $ value = $ key ( $ row ) ; } else { $ value = $ row [ $ key ] ; } if ( ! array_key_exists ( $ value , $ position ) ) { $ position [ $ value ] = [ ] ; } $ position = & $ position [ $ value ] ; } $ position [ ] = $ row ; unset ( $ position ) ; } return $ data ; } | Create an array keyed by the specified field . |
22,056 | public function IsErrorDispatched ( ) { $ toolClass = $ this -> toolClass ; $ defaultCtrlName = $ toolClass :: GetDashedFromPascalCase ( $ this -> defaultControllerName ) ; $ errorActionName = $ toolClass :: GetDashedFromPascalCase ( $ this -> defaultControllerErrorActionName ) ; return $ this -> request -> GetControllerName ( ) == $ defaultCtrlName && $ this -> request -> GetActionName ( ) == $ errorActionName ; } | Return TRUE if current request is default controller error action dispatching process . |
22,057 | public function IsNotFoundDispatched ( ) { $ toolClass = $ this -> toolClass ; $ defaultCtrlName = $ toolClass :: GetDashedFromPascalCase ( $ this -> defaultControllerName ) ; $ errorActionName = $ toolClass :: GetDashedFromPascalCase ( $ this -> defaultControllerNotFoundActionName ) ; return $ this -> request -> GetControllerName ( ) == $ defaultCtrlName && $ this -> request -> GetActionName ( ) == $ errorActionName ; } | Return TRUE if current request is default controller not found error action dispatching process . |
22,058 | protected function & setCoreClass ( $ newCoreClassName , $ coreClassVar , $ coreClassInterface ) { if ( call_user_func ( [ $ this -> toolClass , 'CheckClassInterface' ] , $ newCoreClassName , $ coreClassInterface , TRUE , TRUE ) ) $ this -> $ coreClassVar = $ newCoreClassName ; return $ this ; } | Set core class name only if given class string implements given core interface else thrown an exception . |
22,059 | protected function & setHandler ( array & $ handlers , callable $ handler , $ priorityIndex = NULL ) { $ closureCalling = ( ( is_string ( $ handler ) && strpos ( $ handler , '::' ) !== FALSE ) || ( is_array ( $ handler ) && strpos ( $ handler [ 1 ] , '::' ) !== FALSE ) ) ? FALSE : TRUE ; if ( $ priorityIndex === NULL ) { $ handlers [ ] = [ $ closureCalling , $ handler ] ; } else { if ( isset ( $ handlers [ $ priorityIndex ] ) ) { array_splice ( $ handlers , $ priorityIndex , 0 , [ $ closureCalling , $ handler ] ) ; } else { $ handlers [ $ priorityIndex ] = [ $ closureCalling , $ handler ] ; } } return $ this ; } | Set pre - route pre - dispatch or post - dispatch handler under specific priority index . |
22,060 | public function onCreatePropertyCondition ( CreatePropertyConditionEvent $ event ) { if ( ! $ this -> scopeMatcher -> currentScopeIsFrontend ( ) ) { return ; } $ meta = $ event -> getData ( ) ; if ( 'conditionpropertyvalueis' !== $ meta [ 'type' ] ) { return ; } $ metaModel = $ event -> getMetaModel ( ) ; $ attribute = $ metaModel -> getAttributeById ( $ meta [ 'attr_id' ] ) ; if ( ! ( $ attribute instanceof Checkbox ) ) { return ; } if ( ( bool ) $ meta [ 'value' ] ) { $ event -> setInstance ( new PropertyTrueCondition ( $ attribute -> getColName ( ) ) ) ; return ; } $ event -> setInstance ( new PropertyFalseCondition ( $ attribute -> getColName ( ) ) ) ; } | Handle the CreatePropertyConditionEvent event . |
22,061 | public static function getClassNameFromFile ( $ file ) { $ fp = fopen ( $ file , 'r' ) ; $ class = $ namespace = $ buffer = '' ; $ i = 0 ; while ( ! $ class ) { if ( feof ( $ fp ) ) { break ; } for ( $ line = 0 ; $ line <= 20 ; $ line ++ ) { $ buffer .= fgets ( $ fp ) ; } $ tokens = @ token_get_all ( $ buffer ) ; if ( strpos ( $ buffer , '{' ) === false ) { continue ; } for ( ; $ i < count ( $ tokens ) ; $ i ++ ) { if ( $ tokens [ $ i ] [ 0 ] === T_NAMESPACE ) { for ( $ j = $ i + 1 ; $ j < count ( $ tokens ) ; $ j ++ ) { if ( $ tokens [ $ j ] [ 0 ] === T_STRING ) { $ namespace .= '\\' . $ tokens [ $ j ] [ 1 ] ; } elseif ( $ tokens [ $ j ] === '{' || $ tokens [ $ j ] === ';' ) { break ; } } } if ( $ tokens [ $ i ] [ 0 ] === T_CLASS ) { for ( $ j = $ i + 1 ; $ j < count ( $ tokens ) ; $ j ++ ) { if ( $ tokens [ $ j ] === '{' ) { $ class = $ tokens [ $ i + 2 ] [ 1 ] ; } } } } } ; if ( ! $ class ) { return ; } return $ namespace . '\\' . $ class ; } | Return the class name from a file . |
22,062 | private function configureTwigBundle ( ContainerBuilder $ container ) { $ name = 'twig' ; $ configs = $ container -> getExtensionConfig ( $ name ) ; foreach ( $ configs as $ config ) { if ( isset ( $ config [ 'form_themes' ] ) ) { $ formConfig = [ 'form_themes' => $ config [ 'form_themes' ] ] ; } } if ( ! empty ( $ formConfig ) ) { $ formConfig [ 'form_themes' ] [ ] = $ this -> formTemplate ; } else { $ formConfig = [ 'form_themes' => [ $ this -> formTemplate ] , ] ; } $ container -> prependExtensionConfig ( $ name , $ formConfig ) ; } | Adds the confirm form template to the TwigBundle configuration . |
22,063 | public static function & GetNamespace ( $ name = \ MvcCore \ ISession :: DEFAULT_NAMESPACE_NAME ) { if ( ! static :: GetStarted ( ) ) static :: Start ( ) ; if ( ! isset ( static :: $ instances [ $ name ] ) ) { static :: $ instances [ $ name ] = new static ( $ name ) ; } $ result = & static :: $ instances [ $ name ] ; return $ result ; } | Get new or existing MvcCore session namespace instance . If session is not started start session . |
22,064 | public function buildAsProduction ( Collection $ collection , $ group ) { $ assets = $ collection -> getAssetsWithoutRaw ( $ group ) ; $ entry = $ this -> manifest -> make ( $ identifier = $ collection -> getIdentifier ( ) ) ; $ build = array_to_newlines ( $ assets -> map ( function ( $ asset ) { return $ asset -> build ( true ) ; } ) -> all ( ) ) ; if ( empty ( $ build ) ) { $ entry -> resetProductionFingerprint ( $ group ) ; throw new BuildNotRequiredException ; } $ fingerprint = $ identifier . '-' . md5 ( $ build ) . '.' . $ collection -> getExtension ( $ group ) ; $ path = $ this -> buildPath . '/' . $ fingerprint ; if ( $ fingerprint == $ entry -> getProductionFingerprint ( $ group ) and ! $ this -> force and $ this -> files -> exists ( $ path ) ) { throw new BuildNotRequiredException ; } else { $ this -> files -> put ( $ path , $ this -> gzip ( $ build ) ) ; $ entry -> setProductionFingerprint ( $ group , $ fingerprint ) ; } } | Build a production collection . |
22,065 | public function buildAsDevelopment ( Collection $ collection , $ group ) { $ assets = $ collection -> getAssetsWithoutRaw ( $ group ) ; $ entry = $ this -> manifest -> make ( $ identifier = $ collection -> getIdentifier ( ) ) ; if ( $ this -> collectionDefinitionHasChanged ( $ assets , $ entry , $ group ) or $ this -> force ) { $ entry -> resetDevelopmentAssets ( $ group ) ; } else { $ assets = $ assets -> filter ( function ( $ asset ) use ( $ entry ) { return ! $ entry -> hasDevelopmentAsset ( $ asset ) or $ asset -> getBuildPath ( ) != $ entry -> getDevelopmentAsset ( $ asset ) ; } ) ; } if ( ! $ assets -> isEmpty ( ) ) { foreach ( $ assets as $ asset ) { $ path = "{$this->buildPath}/{$identifier}/{$asset->getBuildPath()}" ; ! $ this -> files -> exists ( $ directory = dirname ( $ path ) ) and $ this -> files -> makeDirectory ( $ directory , 0777 , true ) ; $ this -> files -> put ( $ path , $ this -> gzip ( $ asset -> build ( ) ) ) ; $ entry -> addDevelopmentAsset ( $ asset ) ; } } else { throw new BuildNotRequiredException ; } } | Build a development collection . |
22,066 | protected function collectionDefinitionHasChanged ( $ assets , $ entry , $ group ) { if ( ! $ entry -> hasDevelopmentAssets ( $ group ) ) { return true ; } $ manifest = $ entry -> getDevelopmentAssets ( $ group ) ; $ manifest = array_flatten ( array_keys ( $ manifest ) ) ; $ difference = array_diff_assoc ( $ manifest , $ assets -> map ( function ( $ asset ) { return $ asset -> getRelativePath ( ) ; } ) -> flatten ( ) -> toArray ( ) ) ; return ! empty ( $ difference ) ; } | Determine if the collections definition has changed when compared to the manifest . |
22,067 | protected function makeBuildPath ( ) { if ( ! $ this -> files -> exists ( $ this -> buildPath ) ) { $ this -> files -> makeDirectory ( $ this -> buildPath ) ; } } | Make the build path if it does not exist . |
22,068 | public function initDefaultProperties ( ) { if ( ! empty ( $ this -> schema -> properties ) ) { foreach ( $ this -> schema -> properties as $ property_name => $ property ) { if ( $ this -> setPropertyDefaultValue ( $ property ) ) { $ this -> property_values -> $ property_name = $ this -> getFactory ( ) -> create ( $ property , $ this -> schema_path ) ; } } } } | Instantiate any properties which have default values . |
22,069 | public function get ( $ property_name = null ) { if ( ! isset ( $ property_name ) ) { return $ this -> property_values ; } if ( isset ( $ this -> property_values -> $ property_name ) && is_object ( $ this -> property_values -> $ property_name ) && get_class ( $ this ) == get_class ( $ this -> property_values -> $ property_name ) ) { return $ this -> property_values -> $ property_name ; } if ( isset ( $ this -> property_values -> $ property_name ) && is_object ( $ this -> property_values -> $ property_name ) && $ this -> property_values -> $ property_name instanceof PropertyInterface ) { return $ this -> property_values -> $ property_name -> get ( ) ; } elseif ( isset ( $ this -> property_values -> $ property_name ) ) { return $ this -> property_values -> $ property_name ; } return ; } | Get a properties value . |
22,070 | public function validate ( $ notify = false ) { $ validator = $ this -> getValidator ( ) ; if ( $ validator ) { $ schema = clone $ this -> schema ; $ this -> resolver -> resolve ( $ schema , $ this -> schema_path ) ; $ values = $ this -> flatValue ( ) ; if ( isset ( $ values ) ) { $ validator -> check ( $ values , $ schema ) ; if ( ! $ validator -> isValid ( ) ) { $ errors = $ validator -> getErrors ( ) ; if ( empty ( $ errors ) ) { $ errors = array ( array ( 'property' => $ this -> schema_path , 'message' => 'The JSON schema failed validation.' , 'constraint' => null , ) ) ; } if ( $ notify ) { foreach ( $ errors as $ error ) { $ error_keys = array ( '%name' => $ this -> schema_name , '%message' => $ error [ 'message' ] , '%property' => isset ( $ error [ 'property' ] ) ? $ error [ 'property' ] : 'property' , '%constraint' => isset ( $ error [ 'constraint' ] ) ? $ error [ 'constraint' ] : 'unknown' , ) ; $ this -> logger -> notice ( 'Schema Validation: "%message" in schema "%name", property "%property" for constraint %constraint' , $ error_keys ) ; } } return $ errors ; } } } return true ; } | Validate a properties value . |
22,071 | public function render ( ) { $ template_variables = $ this -> prepareRender ( ) ; if ( $ this -> configuration -> developerMode ( ) ) { $ this -> validate ( true ) ; } $ template_array = json_decode ( json_encode ( $ template_variables ) , true ) ; if ( ! empty ( $ template_variables -> template ) ) { return $ this -> twig -> render ( $ template_variables -> template , $ template_array ) ; } else { $ log_vars = array ( '%schema' => '' ) ; if ( isset ( $ this -> schema_name ) ) { $ log_vars [ '%schema' ] = $ this -> schema_name ; } elseif ( isset ( $ this -> schema_path ) ) { $ log_vars [ '%schema' ] = $ this -> schema_path ; } $ this -> logger -> notice ( 'Cannot render: Missing template property in schema %schema.' , $ log_vars ) ; } } | Render the object . |
22,072 | public function prepareTemplateVariables ( $ variables ) { if ( ! isset ( $ variables ) ) { $ variables = new \ stdClass ( ) ; } if ( ! isset ( $ variables -> name ) && ! empty ( $ this -> schema_name ) ) { $ variables -> name = $ this -> schema_name ; } if ( ! isset ( $ variables -> template ) && ( $ theme = $ this -> getTheme ( ) ) ) { $ variables -> template = $ theme ; } } | Prepare template variables . |
22,073 | private function getValue ( array $ values , $ languages , $ group , $ parent = NULL ) { foreach ( $ values as $ key => $ value ) { foreach ( $ languages as $ language ) { $ entry = Translation :: firstOrCreate ( [ 'key' => $ key , 'language' => $ language , 'translation_group' => $ group -> id , 'parent' => $ parent ] ) ; if ( is_array ( $ value ) ) { $ this -> getValue ( $ value , $ languages , $ group , $ entry -> id ) ; } else { if ( $ entry -> value === NULL ) { $ entry -> value = $ value ; $ entry -> save ( ) ; } } } } } | Writes all translation to database . Updates values if they already exist . Keeps care of multidimensional arrays . |
22,074 | private function updateTranslationGroups ( $ groupname ) { $ group = TranslationGroup :: firstOrCreate ( [ 'name' => $ groupname ] ) ; array_push ( $ this -> translation_groups , $ group ) ; } | Creates new translation - group if it doesn t exists already . |
22,075 | public function setLevel ( $ level ) { if ( $ level < 0 || $ level > 100 ) { throw new \ InvalidArgumentException ( sprintf ( 'Invalid Postrize Level "%s"' , ( string ) $ level ) ) ; } $ this -> level = ( int ) $ level ; return $ this ; } | Set postrize level |
22,076 | public static function & GetInstance ( array $ routes = [ ] , $ autoInitialize = TRUE ) { if ( ! self :: $ instance ) { $ app = & \ MvcCore \ Application :: GetInstance ( ) ; self :: $ routeClass = $ app -> GetRouteClass ( ) ; self :: $ routerClass = $ app -> GetRouterClass ( ) ; self :: $ toolClass = $ app -> GetToolClass ( ) ; $ routerClass = $ app -> GetRouterClass ( ) ; $ instance = new $ routerClass ( $ routes , $ autoInitialize ) ; $ instance -> application = & $ app ; self :: $ instance = & $ instance ; } return self :: $ instance ; } | Get singleton instance of \ MvcCore \ Router stored always here . Optionally set routes as first argument . Create proper router instance type at first time by configured class name in \ MvcCore \ Application singleton . |
22,077 | public static function all ( ) { $ command = 'grep --include="*.php" --files-with-matches -r "class" ' . app_path ( ) ; exec ( $ command , $ files ) ; return collect ( $ files ) -> map ( function ( $ file ) { return self :: convertFileToClass ( $ file ) ; } ) -> filter ( function ( $ class ) { return class_exists ( $ class ) && is_subclass_of ( $ class , Model :: class ) ; } ) ; } | Returns a collection of class names for all Eloquent models within your app path . |
22,078 | private static function convertFileToClass ( string $ file ) { $ fh = fopen ( $ file , 'r' ) ; $ namespace = '' ; while ( ( $ line = fgets ( $ fh , 5000 ) ) !== false ) { if ( str_contains ( $ line , 'namespace' ) ) { $ namespace = trim ( str_replace ( [ 'namespace' , ';' ] , '' , $ line ) ) ; break ; } } fclose ( $ fh ) ; $ class = basename ( str_replace ( '.php' , '' , $ file ) ) ; return $ namespace . '\\' . $ class ; } | Converts a file name to a namespaced class name . |
22,079 | public static function utf8EncodeModel ( Model $ model ) { foreach ( $ model -> toArray ( ) as $ key => $ value ) { if ( is_numeric ( $ value ) || ! is_string ( $ value ) ) { continue ; } $ model -> $ key = utf8_encode ( $ value ) ; } return $ model ; } | UTF - 8 encodes the attributes of a model . |
22,080 | public static function getNextId ( Model $ model ) { $ statement = DB :: select ( 'show table status like \'' . $ model -> getTable ( ) . '\'' ) ; if ( ! isset ( $ statement [ 0 ] ) || ! isset ( $ statement [ 0 ] -> Auto_increment ) ) { throw new \ Exception ( 'Unable to retrieve next auto-increment id for this model.' ) ; } return ( int ) $ statement [ 0 ] -> Auto_increment ; } | Gets the next auto - increment id for a model |
22,081 | public static function areRelated ( ... $ relations ) { try { $ max_key = count ( $ relations ) - 1 ; foreach ( $ relations as $ key => $ current ) { if ( ! is_array ( $ current ) ) { $ previous = null ; if ( $ key > 0 ) { $ previous = $ relations [ $ key - 1 ] ; $ previous = is_array ( $ previous ) ? $ previous [ 0 ] : $ previous ; } $ basename = strtolower ( class_basename ( $ current ) ) ; $ method = Str :: plural ( $ basename ) ; if ( ! is_null ( $ previous ) ) { if ( ! method_exists ( $ previous , $ method ) ) { $ method = Str :: singular ( $ basename ) ; } if ( ! method_exists ( $ previous , $ method ) ) { throw new \ Exception ( 'UNABLE_TO_FIND_RELATIONSHIP' ) ; } } $ relations [ $ key ] = [ $ current , $ method ] ; } if ( ! ( $ relations [ $ key ] [ 0 ] instanceof Model ) ) { throw new \ InvalidArgumentException ( 'INVALID_MODEL' ) ; } } foreach ( $ relations as $ key => $ current ) { if ( $ key !== $ max_key ) { $ model = $ current [ 0 ] ; $ relation = $ relations [ $ key + 1 ] ; $ model -> { $ relation [ 1 ] } ( ) -> findOrFail ( $ relation [ 0 ] -> id ) ; } } return true ; } catch ( \ Illuminate \ Database \ Eloquent \ ModelNotFoundException $ e ) { return false ; } } | Check if any number of models are related to each other |
22,082 | public function IsXmlOutput ( ) { if ( isset ( $ this -> headers [ 'Content-Type' ] ) ) { $ value = $ this -> headers [ 'Content-Type' ] ; return strpos ( $ value , 'xml' ) !== FALSE ; } return FALSE ; } | Returns if response has any xml substring in Content - Type header . |
22,083 | public function Send ( ) { if ( $ this -> IsSent ( ) ) return ; $ httpVersion = $ this -> GetHttpVersion ( ) ; $ code = $ this -> GetCode ( ) ; $ status = $ this -> codeMessage !== NULL ? ' ' . $ this -> codeMessage : ( isset ( static :: $ codeMessages [ $ code ] ) ? ' ' . static :: $ codeMessages [ $ code ] : '' ) ; if ( ! isset ( $ this -> headers [ 'Content-Encoding' ] ) ) { if ( ! $ this -> encoding ) $ this -> encoding = 'utf-8' ; $ this -> headers [ 'Content-Encoding' ] = $ this -> encoding ; } $ this -> UpdateHeaders ( ) ; header ( $ httpVersion . ' ' . $ code . $ status ) ; header ( 'Host: ' . $ this -> request -> GetHost ( ) ) ; foreach ( $ this -> headers as $ name => $ value ) { if ( $ name == 'Content-Type' ) { $ charsetMatched = FALSE ; $ charsetPos = strpos ( $ value , 'charset' ) ; if ( $ charsetPos !== FALSE ) { $ equalPos = strpos ( $ value , '=' , $ charsetPos ) ; if ( $ equalPos !== FALSE ) $ charsetMatched = TRUE ; } if ( ! $ charsetMatched ) $ value .= ';charset=' . $ this -> encoding ; } if ( isset ( $ this -> disabledHeaders [ $ name ] ) ) { header_remove ( $ name ) ; } else { header ( $ name . ": " . $ value ) ; } } foreach ( $ this -> disabledHeaders as $ name => $ b ) header_remove ( $ name ) ; $ this -> addTimeAndMemoryHeader ( ) ; echo $ this -> body ; if ( ob_get_level ( ) ) echo ob_get_clean ( ) ; flush ( ) ; $ this -> sent = TRUE ; } | Send all HTTP headers and send response body . |
22,084 | public function getSites ( $ env = '' , $ includeSite404Table = false ) { $ select = $ this -> tableGateway -> getSql ( ) -> select ( ) ; $ select -> columns ( array ( '*' ) ) ; if ( $ includeSite404Table ) { $ select -> join ( 'melis_cms_site_domain' , 'melis_cms_site_domain.sdom_site_id = melis_cms_site.site_id' , array ( '*' ) , $ select :: JOIN_LEFT ) -> join ( 'melis_cms_site_404' , 'melis_cms_site_404.s404_site_id = melis_cms_site.site_id' , array ( '*' ) , $ select :: JOIN_LEFT ) ; } else { $ select -> join ( 'melis_cms_site_domain' , 'melis_cms_site_domain.sdom_site_id = melis_cms_site.site_id' , array ( '*' ) , $ select :: JOIN_LEFT ) ; } if ( $ env != '' ) $ select -> where ( "sdom_env = '$env'" ) ; $ resultSet = $ this -> tableGateway -> selectWith ( $ select ) ; return $ resultSet ; } | Gets all the datas for a site |
22,085 | public function getSiteById ( $ idSite , $ env , $ includeSite404Table = false ) { $ cacheKey = get_class ( $ this ) . '_getSiteById_' . $ idSite . '_' . $ env . '_' . $ includeSite404Table ; $ cacheConfig = 'engine_page_services' ; $ melisEngineCacheSystem = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineCacheSystem' ) ; $ results = $ melisEngineCacheSystem -> getCacheByKey ( $ cacheKey , $ cacheConfig ) ; if ( ! empty ( $ results ) ) return $ results ; $ select = $ this -> tableGateway -> getSql ( ) -> select ( ) ; $ select -> columns ( array ( '*' ) ) ; $ siteDomainjoin = new Expression ( 'melis_cms_site_domain.sdom_site_id = melis_cms_site.site_id AND sdom_env =\'' . $ env . '\'' ) ; if ( $ includeSite404Table ) { $ site404join = new Expression ( 'melis_cms_site_domain.sdom_site_id = melis_cms_site.site_id' ) ; $ select -> join ( 'melis_cms_site_domain' , $ siteDomainjoin , array ( '*' ) , $ select :: JOIN_LEFT ) -> join ( 'melis_cms_site_404' , $ site404join , array ( '*' ) , $ select :: JOIN_LEFT ) ; } else { $ select -> join ( 'melis_cms_site_domain' , $ siteDomainjoin , array ( '*' ) , $ select :: JOIN_LEFT ) ; } $ select -> where ( 'site_id =' . $ idSite ) ; $ resultSet = $ this -> tableGateway -> selectWith ( $ select ) ; $ melisEngineCacheSystem -> setCacheByKey ( $ cacheKey , $ cacheConfig , $ resultSet ) ; return $ resultSet ; } | Gets a site by its id and can restrict to an environment for the domain and 404 datas |
22,086 | public function setFilter ( $ filter ) { $ validFilters = self :: NO_FILTER | self :: FILTER_NONE | self :: FILTER_SUB | self :: FILTER_UP | self :: FILTER_AVG | self :: FILTER_PAETH | self :: ALL_FILTERS ; $ filter = $ filter & $ validFilters ; $ this -> filter = ( integer ) $ filter ; return $ this ; } | Set the png filter constant |
22,087 | public static function isPngFile ( $ filename ) { try { $ image = new ImageFile ( $ filename ) ; if ( strtolower ( $ image -> getMime ( ) ) !== @ image_type_to_mime_type ( IMAGETYPE_PNG ) ) { return false ; } return true ; } catch ( \ RuntimeException $ ex ) { return false ; } } | Check if the given file is png file |
22,088 | protected function saveAlpha ( Png $ png , $ flag ) { if ( $ flag ) { $ png -> alphaBlending ( false ) ; if ( false == @ imagesavealpha ( $ png -> getHandler ( ) , $ flag ) ) { throw new CanvasException ( sprintf ( 'Faild Saving The Alpha Channel Information To The Png Canvas "%s"' , ( string ) $ this ) ) ; } } return $ this ; } | Save The Alpha Channel Information For Png Resource |
22,089 | protected function getResizedFilename ( $ filepath , $ width , $ height , $ crop ) { $ filename = basename ( $ filepath ) ; $ extension_pattern = '/(\.[^\.]+)$/' ; $ replacement = '-' . $ width . 'x' . $ height . ( $ crop ? '-cropped' : '' ) . '$1' ; return preg_replace ( $ extension_pattern , $ replacement , $ filename ) ; } | Get a suitable name for a resized version of an image file . |
22,090 | protected function store ( $ source , $ destination , $ width , $ height , $ crop ) { if ( file_exists ( $ destination ) ) { return $ destination ; } $ editor = wp_get_image_editor ( $ source ) ; if ( is_wp_error ( $ editor ) ) { return '' ; } $ editor -> resize ( $ width , $ height , $ crop ) ; $ editor -> save ( $ destination ) ; return $ destination ; } | Resize and store a copy of an image file . |
22,091 | public function GetCurrentViewFullPath ( ) { $ result = NULL ; $ renderedFullPaths = & $ this -> __protected [ 'renderedFullPaths' ] ; $ count = count ( $ renderedFullPaths ) ; if ( $ count > 0 ) $ result = $ renderedFullPaths [ $ count - 1 ] ; return $ result ; } | Get currently rendered view file full path . If this method is called outside of rendering process NULL is returned . |
22,092 | public function GetCurrentViewDirectory ( ) { $ result = $ this -> GetCurrentViewFullPath ( ) ; $ lastSlashPos = mb_strrpos ( $ result , '/' ) ; if ( $ lastSlashPos !== FALSE ) { $ result = mb_substr ( $ result , 0 , $ lastSlashPos ) ; } return $ result ; } | Get currently rendered view file directory full path . If this method is called outside of rendering process NULL is returned . |
22,093 | public function withAttribute ( string $ offset , $ value ) : self { if ( $ this -> restricted ) { if ( ! in_array ( $ offset , array_keys ( $ this -> attributes ) ) ) { $ message = sprintf ( '%s it not an allowed attribute on this object. The only allowed attributes are %s' , $ offset , implode ( ',' , array_keys ( $ this -> attributes ) ) ) ; throw new \ InvalidArgumentException ( $ message ) ; } } $ that = clone ( $ this ) ; $ that -> attributes [ $ offset ] = $ value ; return $ that ; } | Returns a new instance of the object with the attribute set . |
22,094 | public function build ( ) { $ fixer = new VendorDirectoryFixer ( ) ; $ translator = new Translator ( $ this -> locale ) ; $ pos = strpos ( $ this -> locale , '_' ) ; $ file = 'validators.' . ( $ pos ? substr ( $ this -> locale , 0 , $ pos ) : $ this -> locale ) . '.xlf' ; $ translator -> addLoader ( 'xlf' , new XliffFileLoader ( ) ) ; $ translator -> addResource ( 'xlf' , $ fixer -> getLocation ( 'form' , self :: FORM_TRANSLATIONS_DIR . $ file ) , $ this -> locale , self :: TRANSLATION_DOMAIN ) ; $ translator -> addResource ( 'xlf' , $ fixer -> getLocation ( 'validator' , self :: VALIDATOR_TRANSLATIONS_DIR . $ file ) , $ this -> locale , self :: TRANSLATION_DOMAIN ) ; return $ translator ; } | Builds a translator |
22,095 | public function getDataBySiteIdAndPageId ( $ siteId , $ pageId ) { $ select = $ this -> tableGateway -> getSql ( ) -> select ( ) ; $ select -> columns ( array ( '*' ) ) ; $ select -> where ( array ( "s404_site_id" => $ siteId , 's404_page_id' => $ pageId ) ) ; $ resultSet = $ this -> tableGateway -> selectWith ( $ select ) ; return $ resultSet ; } | Gets the 404 for a siteId and main page_id |
22,096 | public function has ( $ key ) { if ( $ this -> needParser ( ) ) { $ this -> treatPutRequest ( ) ; return array_key_exists ( $ key , $ _REQUEST ) ; } return parent :: has ( $ key ) ; } | Determine if the request contains a non - empty value for an input item . |
22,097 | protected function isValidFile ( $ file ) { if ( ! is_file ( $ file ) || ! is_readable ( $ file ) ) { throw new \ InvalidArgumentException ( sprintf ( 'File "%s" Is Not Readable' , ( string ) $ file ) ) ; } } | Check if the given string represents a path to a readable file |
22,098 | protected function preserveAlpha ( $ dest , $ src ) { $ transparent = @ imagecolortransparent ( $ src ) ; if ( - 1 != $ transparent ) { $ color = @ imagecolorsforindex ( $ src , $ transparent ) ; $ allocated = @ imagecolorallocatealpha ( $ dest , $ color [ 'red' ] , $ color [ 'green' ] , $ color [ 'blue' ] , $ color [ 'alpha' ] ) ; @ imagecolortransparent ( $ dest , $ allocated ) ; @ imagefill ( $ dest , 0 , 0 , $ allocated ) ; } } | Preserve transparent color read from another resource on given resource |
22,099 | public function extend ( Contracts \ Listener $ listener ) : self { $ listener -> handle ( $ this -> getLogger ( ) ) ; return $ this ; } | Extend the profiler . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.