idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
237,000 | protected function checkForMorePages ( ) { $ this -> hasMore = count ( $ this -> items ) > ( $ this -> perPage ) ; $ this -> items = $ this -> items -> slice ( 0 , $ this -> perPage ) ; } | Check for more pages . The last item will be sliced off . |
237,001 | public static function getMemberValueArrayForObjects ( $ member , $ objects ) { $ returnValues = array ( ) ; foreach ( $ objects as $ key => $ value ) { if ( is_object ( $ value ) ) { if ( $ value instanceof SerialisableObject ) { $ returnValues [ $ key ] = $ value -> __getSerialisablePropertyValue ( $ member ) ; } els... | Get an array of member values for a given member for the array of objects passed using the same indexing system as the passed objects . |
237,002 | public static function indexArrayOfObjectsByMember ( $ member , $ objects ) { $ returnValues = array ( ) ; foreach ( $ objects as $ object ) { if ( $ object instanceof SerialisableObject ) { $ returnValues [ $ object -> __getSerialisablePropertyValue ( $ member ) ] = $ object ; } else { throw new ClassNotSerialisableEx... | Index the array of passed objects by the supplied member returning an associative array . |
237,003 | public static function filterArrayOfObjectsByMember ( $ member , $ objects , $ filterValue ) { $ filterValues = is_array ( $ filterValue ) ? $ filterValue : array ( $ filterValue ) ; $ filteredObjects = array ( ) ; foreach ( $ objects as $ object ) { if ( $ object instanceof SerialisableObject ) { foreach ( $ filterVal... | Filter an array of objects by a specified member . Perhaps in the future extend to multiple match types . |
237,004 | public static function groupArrayOfObjectsByMember ( $ member , $ objects ) { if ( ! is_array ( $ member ) ) $ member = array ( $ member ) ; $ leafMember = array_pop ( $ member ) ; $ groupedObjects = new AssociativeArray ( ) ; foreach ( $ objects as $ object ) { $ rootNode = $ groupedObjects ; foreach ( $ member as $ m... | Group an array of objects by a given member . |
237,005 | private function saveFile ( ) { $ dirMedia = $ this -> filesystem -> getDirectoryWrite ( ADirList :: MEDIA ) ; $ dirTarget = $ dirMedia -> getAbsolutePath ( self :: MEDIA_SUBFOLDER ) ; $ fileId = self :: FIELDSET . '[' . self :: FIELD_CSV_FILE . ']' ; $ uploader = $ this -> factUploader -> create ( [ 'fileId' => $ file... | Save uploading file to the media folder |
237,006 | public function getBackendLayoutForPage ( int $ uid ) { $ rootLine = $ this -> pageRepository -> getRootLine ( $ uid ) ; if ( $ rootLine ) { $ index = - 1 ; foreach ( $ rootLine as $ page ) { $ index ++ ; $ backendLayout = $ page [ 'backend_layout' ] ; $ hasBackendLayout = false ; $ backendLayoutNextLevel = $ page [ 'b... | Gets the backend layout for a page . |
237,007 | public function generateThumbUrl ( MediaInterface $ media ) { $ path = null ; if ( $ media -> getType ( ) === MediaTypes :: IMAGE ) { $ path = $ this -> cacheManager -> getBrowserPath ( $ media -> getPath ( ) , 'media_thumb' ) ; } else { $ path = $ this -> generateFileThumb ( $ media ) ; } if ( null === $ path ) { $ pa... | Generates a thumb for the given media . |
237,008 | public function generateFrontUrl ( MediaInterface $ media ) { $ path = null ; if ( $ media -> getType ( ) === MediaTypes :: IMAGE ) { $ path = $ this -> cacheManager -> getBrowserPath ( $ media -> getPath ( ) , 'media_front' ) ; } elseif ( in_array ( $ media -> getType ( ) , [ MediaTypes :: VIDEO , MediaTypes :: AUDIO ... | Generates the default front url . |
237,009 | private function generateFileThumb ( MediaInterface $ media ) { $ extension = $ media -> guessExtension ( ) ; $ thumbPath = sprintf ( '/%s/%s.jpg' , $ this -> thumbsDirectory , $ extension ) ; $ destination = $ this -> webRootDirectory . $ thumbPath ; if ( file_exists ( $ destination ) ) { return $ thumbPath ; } $ back... | Generates thumb for non - image elements . |
237,010 | private function checkDir ( $ dir ) { if ( ! $ this -> fs -> exists ( $ dir ) ) { $ this -> fs -> mkdir ( $ dir ) ; } } | Creates the directory if it does not exists . |
237,011 | public function splitIsbn ( $ isbn ) { if ( ! $ this -> validateIsbn ( $ isbn ) ) { return false ; } $ prefix = substr ( $ isbn , 0 , 3 ) ; $ groupnumber = $ this -> getGroupNumber ( $ isbn ) ; $ pubnumber = $ this -> getPublisherNumber ( $ isbn ) ; $ prenumbers = strlen ( $ groupnumber ) + strlen ( $ pubnumber ) + 3 ;... | Splits a valid ISBN - 13 Number in its components |
237,012 | public function validateIsbn ( $ check ) { $ ean = strval ( $ check ) ; $ code = substr ( $ ean , 0 , - 1 ) ; $ key = $ this -> calculateCheckdigit13 ( $ code ) ; $ code .= $ key ; if ( $ code == $ ean ) { return true ; } else { return false ; } } | Validates an ISBN - 13 Number |
237,013 | public function init ( $ config = [ ] ) { if ( isset ( $ _SERVER [ 'HTTP_USER_AGENT' ] ) ) { $ this -> userAgent = $ _SERVER [ 'HTTP_USER_AGENT' ] ; } if ( isset ( $ _SERVER [ 'SERVER_NAME' ] ) ) { $ this -> server = $ _SERVER [ 'SERVER_NAME' ] ; } if ( isset ( $ _SERVER [ 'SERVER_PORT' ] ) ) { $ this -> port = $ _SERV... | Initialises the request . |
237,014 | public function createUrl ( $ route , $ params = [ ] , $ absolute = FALSE ) { $ url = $ this -> script . '/' . $ route ; if ( file_exists ( TEST_LOCK_FILE ) ) { $ url = $ route ; } if ( ! empty ( $ params ) ) { foreach ( $ params as $ value ) { $ url .= "/$value" ; } } if ( $ absolute ) { if ( ! file_exists ( TEST_LOCK... | Creates a http url . |
237,015 | public function handleDatasource ( $ name , $ method , array $ preloadedData , array & $ templateVariables ) { $ this -> name = $ name ; $ datasource = ActionUtils :: createActionDatasource ( $ name , $ method ) ; $ this -> templateVars = & $ templateVariables ; $ this -> currentDatasource = $ datasource ; $ this -> cu... | this is used by the RenderModule when loading data from an element |
237,016 | protected function getTemplateVariable ( $ name , $ default = null ) { return array_key_exists ( $ name , $ this -> templateVars ) ? $ this -> templateVars [ $ name ] : $ default ; } | Used in datasource methods |
237,017 | protected function getRequiredTemplateVariable ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> templateVars ) ) throw new ControllerException ( 'Required template variable [' . $ name . '] is missing' ) ; return $ this -> templateVars [ $ name ] ; } | Used in datasource methods throws ControllerException when value is missing |
237,018 | public function get ( $ type = 'success' ) { $ key = self :: BANDAMA_FLASH_KEY . '_' . $ type ; $ flash = $ this -> session -> get ( $ key ) ; $ this -> session -> delete ( $ key ) ; return $ flash ; } | Get flash message |
237,019 | public function getClient ( ) { if ( ! $ this -> client instanceof Client ) { $ this -> client = new Client ( [ "cookies" => true ] ) ; } return $ this -> client ; } | Returns the Client instance |
237,020 | protected function request ( $ method , $ url , $ options = [ ] ) { $ client = $ this -> getClient ( ) ; try { $ response = $ client -> request ( $ method , $ url , $ options ) ; } catch ( \ GuzzleHttp \ Exception \ ClientException $ e ) { $ response = $ e -> getResponse ( ) ; throw new PeopleMatterException ( $ respon... | Executes a request to the PeopleMatter API |
237,021 | final protected function applyOperator ( \ SelectQueryInterface $ query , $ statement , $ value ) { if ( is_array ( $ value ) && ! Misc :: isIndexed ( $ value ) ) { $ keys = array_keys ( $ value ) ; $ operator = $ keys [ 0 ] ; $ value = $ value [ $ operator ] ; switch ( $ operator ) { case '<>' : if ( is_array ( $ valu... | Apply the operator onto the query |
237,022 | public function attach ( Base $ entity , & $ restingPlace = null ) { if ( ! $ this -> makeableSafetyCheck ( ) ) { return null ; } if ( ! is_a ( $ entity , $ this -> entityClass ) ) { throw new EntityNotCompatibleWithRepositoryException ( $ entity , $ this ) ; } if ( $ key = $ entity -> keyGet ( $ entity ) ) { if ( isse... | Add a entity into the multiton array |
237,023 | public function isAttached ( Base $ entity ) { return false !== array_search ( $ entity , $ this -> instancesPersisted , true ) || false !== array_search ( $ entity , $ this -> instancesUnpersisted , true ) ; } | Is in multiton store . |
237,024 | public function detach ( Base $ entity , & $ detachedFrom = null ) { $ detachedFrom = null ; foreach ( array ( 'Persisted' , 'Unpersisted' ) as $ type ) { $ cache = "instances{$type}" ; $ cache = & $ this -> $ cache ; if ( false !== $ key = array_search ( $ entity , $ cache , true ) ) { unset ( $ cache [ $ key ] ) ; $ ... | Detach a entity from the multiton |
237,025 | public function rekey ( Base $ entity ) { if ( false !== $ key = array_search ( $ entity , $ this -> instancesPersisted , true ) ) { $ newKey = $ entity -> keyGet ( $ entity ) ; if ( isset ( $ this -> instancesPersisted [ $ newKey ] ) and $ entity !== $ this -> instancesPersisted [ $ newKey ] ) { throw new \ RuntimeExc... | A entity s key has changed . If it is in the repository this ll need rekeying |
237,026 | public function find ( $ key , $ disableLateLoading = null , $ cache = true ) { if ( ! is_bool ( $ disableLateLoading ) ) { $ disableLateLoading = false ; } if ( ! $ cache ) { return parent :: find ( $ key , $ disableLateLoading ) ; } if ( is_null ( $ key ) ) { return null ; } elseif ( is_scalar ( $ key ) ) { $ multito... | Multiton . Fuck yeah! |
237,027 | public function make ( array $ data = null ) { $ obj = parent :: make ( $ data ) ; $ this -> instancesUnpersisted [ ] = $ obj ; return $ obj ; } | Make a new entity |
237,028 | public function initByData ( array $ data = null ) { if ( ! $ data ) { return null ; } $ key = call_user_func ( array ( $ this -> entityClass , 'keyGet' ) , $ data ) ; if ( isset ( $ this -> instancesPersisted [ $ key ] ) ) { $ obj = $ this -> instancesPersisted [ $ key ] ; $ obj -> __construct ( $ data ) ; return $ ob... | Entry point for objects where you ve got the data array and you wish to instantiate a object and add to the cache . |
237,029 | public function isCached ( Base $ entity , $ source = self :: PERSISTED ) { switch ( $ source ) { case self :: PERSISTED : return false !== array_search ( $ entity , $ this -> instancesPersisted , true ) ; case self :: UNPERSISTED : return false !== array_search ( $ entity , $ this -> instancesUnpersisted , true ) ; ca... | Is this object in the multiton cache |
237,030 | public function cacheSize ( $ type = self :: PERSISTED ) { switch ( $ type ) { case self :: PERSISTED : return count ( $ this -> instancesPersisted ) ; case self :: UNPERSISTED : return count ( $ this -> instancesUnpersisted ) ; case self :: ALL : return $ this -> cacheSize ( self :: PERSISTED ) + $ this -> cacheSize (... | Returns the number of cached items |
237,031 | public function cacheInvalidate ( $ type = self :: ALL ) { switch ( $ type ) { case self :: PERSISTED : $ return = count ( $ this -> instancesPersisted ) ; $ this -> instancesPersisted = array ( ) ; return $ return ; case self :: UNPERSISTED : $ return = count ( $ this -> instancesUnpersisted ) ; $ this -> instancesUnp... | Invalidate cache . Returns multiton to it s vanilla state . Required for unit testing . |
237,032 | public function garbageCollect ( $ keyOrObject = null ) { if ( $ keyOrObject == null ) { if ( ! is_int ( $ this -> instancesMaxAllowed ) ) { return 0 ; } $ removed = 0 ; reset ( $ this -> instancesPersisted ) ; while ( count ( $ this -> instancesPersisted ) >= $ this -> instancesMaxAllowed && list ( $ key , $ obj ) = e... | Removes a object from the multiton if |
237,033 | protected function isSpamAttempt ( ) { $ dir = $ this -> tmp_path ; $ numPrefixChars = strlen ( $ this -> file_prefix ) ; $ files = scandir ( $ dir ) ; foreach ( $ files as $ file ) { if ( is_file ( $ dir . DIRECTORY_SEPARATOR . $ file ) ) { if ( substr ( $ file , 0 , $ numPrefixChars ) == $ this -> file_prefix ) { $ l... | Detects spam attempts |
237,034 | public function execute ( IDS_Report $ data ) { if ( $ this -> safemode ) { if ( $ this -> isSpamAttempt ( ) ) { return false ; } } $ data = $ this -> prepareData ( $ data ) ; if ( is_string ( $ data ) ) { $ data = trim ( $ data ) ; if ( is_array ( $ this -> headers ) ) { $ headers = "" ; foreach ( $ this -> headers as... | Sends the report to registered recipients |
237,035 | public function toProfile ( $ uid , $ card ) { $ card [ 'canvas' ] = isset ( $ card [ 'canvas' ] ) ? $ card [ 'canvas' ] : self :: DEFAULT_CANVAS ; return $ this -> request -> send ( 'POST' , "/profiles/$uid/cards" , $ card ) ; } | Sends a card to a profile |
237,036 | public function toProfiles ( $ profiles , $ card ) { $ card = array_merge ( [ 'profile_uids' => $ profiles ] , $ card ) ; $ card [ 'canvas' ] = isset ( $ card [ 'canvas' ] ) ? $ card [ 'canvas' ] : self :: DEFAULT_CANVAS ; return $ this -> request -> send ( 'POST' , "/profiles/cards" , $ card ) ; } | Sends a card to a multiple profiles |
237,037 | public function toChannels ( $ channels , $ card ) { $ card = array_merge ( [ 'channel_uids' => $ channels ] , $ card ) ; $ card [ 'canvas' ] = isset ( $ card [ 'canvas' ] ) ? $ card [ 'canvas' ] : self :: DEFAULT_CANVAS ; return $ this -> request -> send ( 'POST' , "/channels/cards" , $ card ) ; } | Sends a card to a multiple channels |
237,038 | public function applyData ( $ applyEntrie = NULL , $ full = true ) { if ( is_array ( $ applyEntrie ) ) { if ( $ full ) { $ this -> values = $ applyEntrie ; } else { $ this -> values = array_replace ( $ this -> values , $ applyEntrie ) ; } } elseif ( is_string ( $ applyEntrie ) ) { if ( $ full ) { $ this -> values = exp... | apply content via string or array |
237,039 | private function checkCount ( ) { $ cnt = ( int ) $ this -> getMaxEntries ( ) ; if ( $ cnt !== NULL && count ( $ this -> values ) !== $ cnt ) { trigger_error ( "Wrong count of Elements. Expected are $cnt. But right now there are " . count ( $ this -> values ) ) ; } } | checks if the expected count is given triggers an error if getMaxEntries Returns a number and this number is not equal to the count of elements . |
237,040 | public function getHTMLGeneratorInstance ( ) { if ( ! isset ( $ this -> HTMLGenerator ) || ! $ this -> HTMLGenerator instanceof HTMLGenerator ) { $ this -> HTMLGenerator = new HTMLGenerator ( ) ; $ this -> HTMLConfig ( $ this -> HTMLGenerator ) ; } return $ this -> HTMLGenerator ; } | Get the generator instance or create one . |
237,041 | public static function isLongCode ( $ arg ) { $ retVal = ( strlen ( $ arg ) > 2 ) && ( '-' === $ arg [ 0 ] && '-' === $ arg [ 1 ] ) ; if ( 2 === strlen ( $ arg ) ) { return $ retVal ; } if ( ( ! is_bool ( $ arg ) && ! Util :: validIndex ( 2 , $ arg ) ) || '-' === $ arg [ 2 ] ) { throw new CommandException ( 'Unknown op... | Checks if the argument is a long code . |
237,042 | public static function setRequiredValue ( Option & $ option , $ arg ) { if ( self :: isShortCode ( $ arg ) || self :: isLongCode ( $ arg ) ) { throw new CommandException ( 'Missing argument for option --' . $ option -> longCode ) ; } else { if ( is_string ( $ arg ) ) { $ arg = trim ( $ arg ) ; } $ option -> value = $ a... | Sets the required argument . |
237,043 | public static function setOptionalValue ( Option & $ option , $ arg ) { if ( ! self :: isShortCode ( $ arg ) && ! self :: isLongCode ( $ arg ) ) { if ( is_bool ( $ arg ) ) { $ option -> value = ( bool ) $ arg ; } elseif ( is_string ( $ arg ) ) { $ arg = trim ( $ arg ) ; $ option -> value = $ arg ; } } } | Sets an optional argument if available . |
237,044 | public function setTableName ( $ table ) { if ( $ this -> sql ) { if ( $ this -> validateToken ( $ table ) ) { $ this -> table = $ table ; return true ; } else { throw new SimpleCache_Exception ( "`$table` is not a valid table name" ) ; } } return false ; } | Set cache table name |
237,045 | public function setKeyName ( $ key ) { if ( $ this -> sql ) { if ( $ this -> validateToken ( $ key ) ) { $ this -> key = $ key ; return true ; } else { throw new SimpleCache_Exception ( "`$key` is not a valid field name" ) ; } } return false ; } | Set cache key field name |
237,046 | public function setCacheName ( $ cache ) { if ( $ this -> sql ) { if ( $ this -> validateToken ( $ cache ) ) { $ this -> cache = $ cache ; return true ; } else { throw new SimpleCache_Exception ( "`$cache` is not a valid field name" ) ; } } return false ; } | Set cache storage field name |
237,047 | public function buildCache ( $ table = null , $ key = null , $ cache = null ) { if ( $ this -> sql && ( $ table === null || $ this -> setTableName ( $ table ) ) && ( $ key === null || $ this -> setKeyName ( $ key ) ) && ( $ cache === null || $ this -> setCacheName ( $ cache ) ) ) { if ( $ this -> sql -> query ( " ... | Create cache table in database |
237,048 | public function getCache ( $ key ) { if ( $ this -> sqlInitialized ( ) ) { if ( $ this -> sql ) { $ _key = $ this -> sql -> real_escape_string ( $ key ) ; if ( $ this -> lifetime == self :: IMMORTAL_LIFETIME ) { if ( $ response = $ this -> sql -> query ( " SELECT * FROM... | Get available cached data |
237,049 | protected function getExpirationTimestamp ( $ lifetimeInSeconds = false ) { if ( $ lifetimeInSeconds === false ) { $ lifetimeInSeconds = $ this -> lifetime ; } if ( $ lifetimeInSeconds === self :: IMMORTAL_LIFETIME ) { return false ; } else { return date ( self :: MYSQL_TIMESTAMP , time ( ) + $ lifetimeInSeconds ) ; } ... | Calculate the expiration timestamp |
237,050 | public function purgeExpired ( ) { if ( $ this -> sqlInitialized ( ) ) { if ( $ this -> sql ) { if ( $ this -> sql -> query ( " DELETE FROM `{$this->table}` WHERE `expire` < NOW() " ) ) { return true ; } } } return false ; } | Purge expired cache data |
237,051 | public function setCache ( $ key , $ data , $ lifetimeInSeconds = false ) { if ( $ this -> sqlInitialized ( ) ) { if ( $ this -> sql ) { $ _key = $ this -> sql -> real_escape_string ( $ key ) ; $ _data = $ this -> sql -> real_escape_string ( serialize ( $ data ) ) ; $ _expire = $ this -> getExpirationTimestamp ( $ life... | Store data in cache |
237,052 | public function getCacheTimestamp ( $ key ) { if ( $ this -> sqlInitialized ( ) ) { $ _key = $ this -> sql -> real_escape_string ( $ key ) ; if ( $ response = $ this -> sql -> query ( " SELECT * FROM `{$this->table}` WHERE `{$this->key}` = '$_k... | Get the timestamp of the cached data |
237,053 | protected function setLoaders ( array $ loaders ) { $ this -> loaders = array ( ) ; foreach ( $ loaders as $ type => $ loader ) { if ( ! $ loader instanceof FormulaLoaderInterface ) { throw new \ InvalidArgumentException ( "Not a valid formula loader with key '${type}'." ) ; } $ this -> setLoader ( $ type , $ loader ) ... | Adds a list of loaders |
237,054 | public function actionJsonProxyPost ( ) { $ url = Cii :: get ( $ _POST , 'url' , false ) ; if ( $ url === false ) throw new CHttpException ( 400 , Yii :: t ( 'Api.index' , 'Missing $_POST[url] parameter' ) ) ; $ hash = md5 ( $ url ) ; $ response = Yii :: app ( ) -> cache -> get ( 'CiiMS::API::Proxy::' . $ hash ) ; if (... | Global proxy for CiiMS to support JavaScript endpoints that either don t have proper CORS headers or SSL This endpoint will only process JSON and will cache data for 10 minutes . |
237,055 | public function compile ( $ output ) { file_exists ( $ output ) || mkdir ( $ output ) ; $ this -> clear ( ( string ) $ output ) ; $ this -> output = ( string ) $ output ; foreach ( ( array ) $ this -> pages as $ page ) { $ folder = $ this -> folder ( $ output , $ page -> uris ( ) ) ; $ html = ( string ) $ this -> html ... | Compiles the specified pages into HTML output . |
237,056 | public function transfer ( $ source , $ path = null ) { $ path = $ path === null ? $ this -> output : $ path ; $ path = $ this -> realpath ( $ path ) ; $ source = ( string ) $ this -> realpath ( $ source ) ; $ directory = new \ RecursiveDirectoryIterator ( $ source , 4096 ) ; $ iterator = new \ RecursiveIteratorIterato... | Transfers files from a directory into another path . |
237,057 | protected function clear ( $ path ) { $ directory = new \ RecursiveDirectoryIterator ( $ path , 4096 ) ; $ iterator = new \ RecursiveIteratorIterator ( $ directory , 2 ) ; foreach ( $ iterator as $ file ) { $ git = strpos ( $ file -> getRealPath ( ) , '.git' ) !== false ; $ path = ( string ) $ file -> getRealPath ( ) ;... | Removes the files recursively from the specified directory . |
237,058 | protected function folder ( $ output , array $ uris ) { $ folder = ( string ) '' ; foreach ( ( array ) $ uris as $ uri ) { $ directory = $ output . '/' . ( string ) $ folder ; file_exists ( $ directory ) ? : mkdir ( $ directory ) ; $ folder === $ uri ? : $ folder .= '/' . $ uri ; } return $ folder ; } | Returns the whole folder path based from specified URIs . Also creates the specified folder if it doesn t exists . |
237,059 | protected function html ( Page $ page ) { $ html = $ this -> content -> make ( $ content = $ page -> content ( ) ) ; if ( ( $ name = $ page -> layout ( ) ) !== null ) { $ data = array_merge ( $ this -> helpers ( ) , ( array ) $ page -> data ( ) ) ; $ layout = new Layout ( $ this -> renderer , $ this , $ data ) ; $ html... | Converts the specified page into HTML . |
237,060 | protected function realpath ( $ folder ) { $ separator = ( string ) DIRECTORY_SEPARATOR ; $ search = array ( '\\' , '/' , ( string ) '\\\\' ) ; $ path = str_replace ( $ search , $ separator , $ folder ) ; file_exists ( $ path ) || mkdir ( ( string ) $ path ) ; $ exists = in_array ( substr ( $ path , - 1 ) , $ search ) ... | Replaces the slashes with the DIRECTORY_SEPARATOR . Also creates the directory if it doesn t exists . |
237,061 | public function execute ( callable $ statusCallback ) { for ( $ this -> iterations = 0 ; $ this -> iterations < 100 ; $ this -> iterations ++ ) { usleep ( 100000 ) ; $ statusCallback ( new TaskStatus ( $ this -> iterations , "Busy bee..." ) ) ; } } | Executes the long running code . |
237,062 | public static function str2url ( $ str ) { $ str = self :: rus2translit ( $ str ) ; $ str = strtolower ( $ str ) ; $ str = preg_replace ( '~[^-a-z0-9_]+~u' , '-' , $ str ) ; $ str = trim ( $ str , "-" ) ; return $ str ; } | String to url |
237,063 | protected function addSuffixNumber ( $ slug , Page $ page , $ number = 0 ) { $ slugTmp = $ number > 0 ? $ slug . $ this -> slugSuffixSeparator . $ number : $ slug ; $ parentFullpath = $ page -> getParent ( ) -> getFullpath ( ) ; $ foundedPage = $ this -> doctrine -> getRepository ( 'FulgurioLightCMSBundle:Page' ) -> fi... | Add suffix number if page exists |
237,064 | public function makeFullpath ( Page $ page ) { if ( $ page -> getParent ( ) === NULL ) { $ page -> setFullpath ( '' ) ; $ page -> setSlug ( '' ) ; } else { $ parentFullpath = $ page -> getParent ( ) -> getFullpath ( ) ; $ slug = $ this -> addSuffixNumber ( $ page -> getSlug ( ) , $ page ) ; $ page -> setFullpath ( ( $ ... | Init page full path and check if it doesn t already exist |
237,065 | private function updatePageMenuPosition ( Page $ page ) { $ pageMenuRepository = $ this -> doctrine -> getRepository ( 'FulgurioLightCMSBundle:PageMenu' ) ; $ em = $ this -> doctrine -> getManager ( ) ; $ data = $ this -> request -> get ( 'page' ) ; if ( isset ( $ data [ 'availableMenu' ] ) ) { if ( ! is_null ( $ page ... | Update page menu position |
237,066 | final public function initMetaEntity ( Page $ page , $ metaName , $ metaValue ) { $ this -> initPageMetas ( $ page ) ; if ( isset ( $ this -> pageMetas [ $ metaName ] ) ) { $ entity = $ this -> pageMetas [ $ metaName ] ; } else { $ entity = new PageMeta ( ) ; $ entity -> setPage ( $ page ) ; $ entity -> setMetaKey ( $ ... | Add or update a PageMeta entity and return it for save |
237,067 | final protected function initPageMetas ( Page $ page ) { if ( ! isset ( $ this -> pageMetas ) ) { $ this -> pageMetas = array ( ) ; if ( $ page -> getId ( ) > 0 ) { $ metas = $ this -> doctrine -> getRepository ( 'FulgurioLightCMSBundle:PageMeta' ) -> findByPage ( $ page -> getId ( ) ) ; foreach ( $ metas as $ meta ) {... | Init page meta of page |
237,068 | public function getClassName ( $ name ) { if ( ! $ this -> has ( $ name ) ) { return false ; } $ helper = $ this -> get ( $ name ) ; return get_class ( $ helper ) ; } | Return full class name for a named helper |
237,069 | public function getItems ( $ offset , $ limit , $ sort = null ) { $ items = [ ] ; $ cnt = count ( $ this -> rawData ) ; for ( $ i = $ offset ; $ i < $ offset + $ limit && $ i < $ cnt ; $ i ++ ) { $ items [ ] = $ this -> rawData [ $ i ] ; } return $ items ; } | This method return an collection of items for a page . |
237,070 | public function overlaps ( IntervalInterface $ interval ) { $ startDate = $ interval -> getStart ( ) ; $ endDate = $ interval -> getEnd ( ) ; return $ this -> checkOverlaping ( $ startDate , $ endDate ) ; } | Checks if the interval overlaps another interval |
237,071 | public function toArray ( ) { $ start = $ this -> intervalStart ; $ end = $ this -> intervalEnd ; $ period = new \ DatePeriod ( $ start , new \ DateInterval ( 'P1D' ) , $ end ) ; $ days = array ( ) ; foreach ( $ period as $ current_day ) { $ days [ ] = $ current_day ; } $ days [ ] = $ end ; return $ days ; } | Array of \ DateTime objects |
237,072 | protected function initializeAttributeOnData ( $ attribute ) { $ explicitPath = $ this -> getLeadingExplicitAttributePath ( $ attribute ) ; $ data = $ this -> extractDataFromPath ( $ explicitPath ) ; if ( ! Str :: contains ( $ attribute , '*' ) || Str :: endsWith ( $ attribute , '*' ) ) { return $ data ; } return data_... | Gather a copy of the attribute data filled with any missing attributes . |
237,073 | protected function shouldStopValidating ( $ attribute ) { if ( ! $ this -> hasRule ( $ attribute , [ 'Bail' ] ) ) { return false ; } return $ this -> messages -> has ( $ attribute ) ; } | Stop on error if bail rule is assigned and attribute has a message . |
237,074 | protected function validateArray ( $ attribute , $ value ) { if ( ! $ this -> hasAttribute ( $ attribute ) ) { return true ; } return is_null ( $ value ) || is_array ( $ value ) ; } | Validate that an attribute is an array . |
237,075 | protected function validateInteger ( $ attribute , $ value ) { if ( ! $ this -> hasAttribute ( $ attribute ) ) { return true ; } return is_null ( $ value ) || filter_var ( $ value , FILTER_VALIDATE_INT ) !== false ; } | Validate that an attribute is an integer . |
237,076 | protected function validateNumeric ( $ attribute , $ value ) { if ( ! $ this -> hasAttribute ( $ attribute ) ) { return true ; } return is_null ( $ value ) || is_numeric ( $ value ) ; } | Validate that an attribute is numeric . |
237,077 | protected function validateString ( $ attribute , $ value ) { if ( ! $ this -> hasAttribute ( $ attribute ) ) { return true ; } return is_null ( $ value ) || is_string ( $ value ) ; } | Validate that an attribute is a string . |
237,078 | protected function validateActiveUrl ( $ attribute , $ value ) { if ( ! is_string ( $ value ) ) { return false ; } if ( $ url = parse_url ( $ value , PHP_URL_HOST ) ) { return count ( dns_get_record ( $ url , DNS_A | DNS_AAAA ) ) > 0 ; } return false ; } | Validate that an attribute is an active URL . |
237,079 | protected function validateAlphaNum ( $ attribute , $ value ) { if ( ! is_string ( $ value ) && ! is_numeric ( $ value ) ) { return false ; } return preg_match ( '/^[\pL\pM\pN]+$/u' , $ value ) ; } | Validate that an attribute contains only alpha - numeric characters . |
237,080 | protected function validateAlphaDash ( $ attribute , $ value ) { if ( ! is_string ( $ value ) && ! is_numeric ( $ value ) ) { return false ; } return preg_match ( '/^[\pL\pM\pN_-]+$/u' , $ value ) ; } | Validate that an attribute contains only alpha - numeric characters dashes and underscores . |
237,081 | public function iRunPhpspec ( $ argumentsString = '' ) { $ argumentsString = strtr ( $ argumentsString , array ( '\'' => '"' ) ) ; $ this -> process -> setWorkingDirectory ( $ this -> workingDir ) ; $ this -> process -> setCommandLine ( sprintf ( '%s %s %s --no-interaction' , $ this -> phpBin , escapeshellarg ( $ this ... | Runs phpspec command with provided parameters |
237,082 | public function filter ( $ value ) { $ filtered = null ; if ( ! $ this -> validate ( $ value , $ filtered ) ) { throw new \ InvalidArgumentException ( "Not a valid value for " . $ this -> __toString ( ) . ": " . WF :: str ( $ value ) ) ; } return $ filtered ; } | Return a properly typed value |
237,083 | public function validate ( $ value , & $ filtered = null ) { $ this -> error = null ; if ( $ value === null ) return $ this -> options [ 'nullable' ] ?? false ; $ filtered = $ value ; if ( $ this -> type === Validator :: EXISTS ) return true ; $ o = $ this -> options ; if ( $ this -> type !== Validator :: VALIDATE_CUST... | Check if the value matches the expected value |
237,084 | protected function numRangeCheck ( $ value , $ min , $ max ) { if ( $ min !== null && $ value < $ min ) return false ; if ( $ max !== null && $ value > $ max ) return false ; return true ; } | Check if the numeric value is between the configured minimum and maximum |
237,085 | public function map ( ) { $ this -> prefix ( 'statuses' ) -> as ( 'statuses.' ) -> group ( function ( ) { $ this -> get ( '/' , 'StatusesController@index' ) -> name ( 'index' ) ; $ this -> post ( 'backup' , 'StatusesController@backup' ) -> middleware ( 'ajax' ) -> name ( 'backup' ) ; $ this -> post ( 'clear' , 'Statuse... | Map the routes for the application . |
237,086 | protected function newDate ( $ desiredTZ , $ date = false ) { if ( $ date === false ) { $ date = 'now' ; } try { $ newDate = new Date ( is_numeric ( '' . $ date ) ? '@' . $ date : $ date , $ desiredTZ ) ; $ newDate -> setTimezone ( $ desiredTZ ) ; } catch ( Exception $ e ) { throw new DateException ( $ e ) ; } unset ( ... | Creates a new date in the desired timezone |
237,087 | public function make ( string $ name , int $ expireTime = 604800 , string $ path = "/" , string $ domain = "" , bool $ secure = false , bool $ httpOnly = true ) { return new PHPCookie ( $ name , $ expireTime , $ path , $ domain , $ secure , $ httpOnly ) ; } | Create a new cookie |
237,088 | public static function deserialize ( string $ json ) { $ deserialized = json_decode ( $ json , true ) ; $ objects = [ ] ; return self :: decode ( $ deserialized , $ objects ) ; } | Deserialize the given JSON string . |
237,089 | private static function setObjectProperties ( $ object , array & $ properties , bool $ isInternal , Closure $ propertyDecoder ) { Closure :: bind ( function ( ) use ( $ object , & $ properties , $ propertyDecoder ) { foreach ( $ properties as $ key => & $ value ) { $ object -> $ key = $ propertyDecoder ( $ value ) ; } ... | Set the given object properties . |
237,090 | public function thumb ( string $ src , string $ dst , integer $ width , integer $ height ) { $ anchor = 'center' ; return $ this -> image ( $ src ) -> thumbnail ( $ width , $ height , $ anchor ) -> toFile ( $ dst ) ; } | Miniatura da imagem |
237,091 | public static function between ( $ min , $ max ) : Compare { $ value = $ min > $ max ? [ $ max , $ min ] : [ $ min , $ max ] ; return new Compare ( 'bt' , $ value ) ; } | Gets a rule that requires numbers to be in a given range . |
237,092 | public function getInfo ( ) { if ( $ this -> info === null ) { $ this -> info = new \ SplFileInfo ( $ this -> fullPath ) ; } return $ this -> info ; } | Get the info |
237,093 | protected function parse ( array $ list ) { $ parsed = array ( ) ; foreach ( $ list as $ item ) { $ item = explode ( ';' , trim ( $ item ) ) ; $ entry = array ( 'encoding' => array_shift ( $ item ) , 'q' => 1 ) ; foreach ( $ item as $ param ) { $ param = explode ( '=' , $ param ) ; if ( count ( $ param ) != 2 ) { conti... | Parses a list of media types out into a normalised structure . |
237,094 | public function authenticate ( $ username , $ password , $ type = self :: AUTH_ANY ) { if ( false === is_string ( $ username ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ username ) ) , E_USER_ERROR ) ; } if ( false === is_string ( $... | Adds a HTTP authentication method |
237,095 | public function addParam ( $ key , $ value , $ encode = false ) { if ( false === is_string ( $ key ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ key ) ) , E_USER_ERROR ) ; } if ( false === is_string ( $ value ) && false === is_array ... | Add a new key value param to the url or query |
237,096 | public function addFile ( $ file , $ name = null , $ mime = null ) { if ( 'post' !== $ this -> method ) { return trigger_error ( 'File uploads are only supported with POST request method' , E_USER_ERROR ) ; } if ( false === $ file instanceof File && false === is_string ( $ file ) ) { return trigger_error ( sprintf ( 'A... | Attach file to request |
237,097 | public function userAgent ( $ useragent ) { if ( false === is_string ( $ useragent ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ useragent ) ) , E_USER_ERROR ) ; } $ this -> options [ CURLOPT_USERAGENT ] = $ useragent ; return $ this... | Set a user agent to the request |
237,098 | public function timeout ( $ connection = 30 , $ response = 30 ) { if ( false === ( '-' . intval ( $ connection ) == '-' . $ connection ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ connection ) ) , E_USER_ERROR ) ; } if ( false === ... | Set the connection and response timeout in seconds for the request |
237,099 | public function referer ( $ referer ) { if ( false === is_string ( $ referer ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ referer ) ) , E_USER_ERROR ) ; } $ this -> options [ CURLOPT_REFERER ] = $ referer ; return $ this ; } | Set the referer |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.