idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
53,300 | protected function deserialize ( ResponseInterface $ response , $ type , $ format = 'json' ) { try { return $ this -> serializer -> deserialize ( ( string ) $ response -> getBody ( ) , $ type , $ format ) ; } catch ( \ Exception $ exception ) { $ this -> logger -> error ( '[WebServiceClient] Deserialization problem on ... | Deserializes request content . |
53,301 | public static function make ( $ uri , $ data = null , array $ queryParameters = [ ] , array $ headers = [ ] , $ method = null , $ contentType = null , $ contentCharset = null ) { if ( is_null ( $ method ) ) { $ method = is_null ( $ data ) ? static :: METHOD_GET : static :: METHOD_POST ; } $ uri = UriFactory :: make ( $... | Makes PSR - 7 compliant Request object from provided parameters |
53,302 | private static function extractCharset ( array $ contentTypeParts ) { foreach ( $ contentTypeParts as $ part ) { $ elements = explode ( '=' , $ part ) ; $ key = trim ( array_shift ( $ elements ) ) ; if ( strtolower ( $ key ) === 'charset' ) { $ value = trim ( reset ( $ elements ) ) ; return $ value ? : null ; } } retur... | Tries to extract charset from pre - parsed part of Content - Type value |
53,303 | public static function hasAction ( $ hook = '' , callable $ callback = null , $ priority = null ) { return static :: hasHook ( 'action' , $ hook , $ callback , $ priority ) ; } | Check if an action hook is added . Optionally check a specific callback and and priority . |
53,304 | public static function hasFilter ( $ hook = '' , callable $ callback = null , $ priority = null ) { return static :: hasHook ( 'filter' , $ hook , $ callback , $ priority ) ; } | Check if an filter hook is added . Optionally check a specific callback and and priority . |
53,305 | public static function hasHookFired ( $ type = 'action' , $ hook = null ) { if ( ! in_array ( $ type , [ 'action' , 'filter' ] , true ) ) { $ type = 'action' ; } $ target = $ type === 'filter' ? 'filters' : 'actions' ; if ( empty ( $ hook ) || ! is_string ( $ hook ) ) { $ msg = __METHOD__ . ' needs a valid hook to chec... | Check if an hook is was fired . |
53,306 | public static function assertActionAdded ( $ hook = '' , $ callback = null , $ priority = null , $ argsNum = null ) { static :: assertHookAdded ( 'action' , $ hook , $ callback , $ priority , $ argsNum ) ; } | Check if an action is added and throws a exceptions otherwise . |
53,307 | public static function assertFilterAdded ( $ hook = '' , callable $ callback = null , $ priority = null , $ numArgs = null ) { static :: assertHookAdded ( 'filter' , $ hook , $ callback , $ priority , $ numArgs ) ; } | Check if a filter is added and throws an exceptions otherwise . |
53,308 | public function getSrcsetAttributeValue ( ) { $ srcset = [ ] ; foreach ( $ this -> versions as $ id ) { $ srcset [ ] = sprintf ( '%s %sw' , $ id -> getUrl ( ) , $ id -> getWidth ( ) ) ; } return join ( ', ' , $ srcset ) ; } | Get the value for the srcset HTML attribute |
53,309 | public function getDefaultImageInfo ( ) { if ( isset ( $ this -> versions [ $ this -> class -> getDefaultWidth ( ) ] ) ) { return $ this -> versions [ $ this -> class -> getDefaultWidth ( ) ] ; } else { return reset ( $ this -> versions ) ; } } | Get WebImageInfo object for the default image size |
53,310 | public function createResizedVersions ( ImageResizer $ resizer ) { foreach ( $ this -> class -> getImageResizeDefinitions ( ) as $ ird ) { $ resizer -> resize ( $ ird , $ this -> original_ifi , true ) ; } } | Really create all resized versions of this image |
53,311 | public function getResizedVersion ( ImageResizer $ resizer , $ width ) { if ( ! $ this -> class -> hasWidth ( $ width ) ) { throw new WidthNotAllowedException ( $ width ) ; } return $ resizer -> resize ( $ this -> class -> getImageResizeDefinitionByWidth ( $ width ) , $ this -> original_ifi , true ) ; } | Resize the image to a defined width and return the corresponding ImageFileInfo object |
53,312 | protected function className ( $ suffix = '' ) { $ exp = explode ( '\\' , $ this -> getClass ( ) ) ; return ( ! empty ( $ suffix ) && substr ( $ exp [ count ( $ exp ) - 1 ] , ( strlen ( $ exp [ count ( $ exp ) - 1 ] ) - strlen ( $ suffix ) ) ) === $ suffix ) ? substr ( $ exp [ count ( $ exp ) - 1 ] , 0 , ( strlen ( $ e... | Fetches the class name |
53,313 | protected function getNamespace ( ) { $ np = explode ( '\\' , $ this -> getClass ( ) ) ; unset ( $ np [ count ( $ np ) - 1 ] ) ; return join ( '\\' , $ np ) ; } | Fetches the namespace of the current class |
53,314 | final protected function ExceptionAsXML ( \ Exception $ e , \ DOMNode & $ par ) { $ exc = $ par -> appendChild ( $ this -> createElement ( 'Exception' ) ) ; $ exc -> appendChild ( $ this -> createElement ( 'File' , $ e -> getFile ( ) ) ) ; $ exc -> appendChild ( $ this -> createElement ( 'Line' , $ e -> getLine ( ) ) )... | Converts a PHP Exception into a populated XML node |
53,315 | public static function boot ( ) { parent :: boot ( ) ; static :: deleting ( function ( $ permission ) { if ( ! method_exists ( config ( 'access.permission' ) , 'bootSoftDeletes' ) ) { $ permission -> roles ( ) -> sync ( [ ] ) ; } return true ; } ) ; } | Boot the permission model Attach event listener to remove the many - to - many records when trying to delete Will NOT delete any records if the permission model uses soft deletes . |
53,316 | public function getLimit ( $ end = false ) { $ bottom = ( $ this -> maxPerPage * ( $ this -> pageCurrent - 1 ) ) ; $ top = $ this -> maxPerPage ; if ( $ end === false ) { return array ( $ bottom , $ top ) ; } if ( $ end === 0 ) { return $ bottom ; } if ( $ end === 1 ) { return $ top ; } } | get a limit array usable in an sql query |
53,317 | public function generate ( $ pageCurrent , $ totalRows ) { $ this -> totalRows = $ totalRows ; $ this -> setPossiblePages ( ) ; $ this -> setPageCurrent ( $ pageCurrent ) ; if ( $ this -> possiblePages < 2 ) { return ; } $ pageCurrent = $ this -> pageCurrent ; $ pagination = $ this -> getPaginationContainer ( ) ; if ( ... | build the pagination array |
53,318 | protected function urlBuildPageLink ( $ page ) { $ url = $ this -> url ; $ urlBase = $ url -> generate ( ) . $ url -> getPath ( ) ; $ queryParts = $ url -> getQueryArray ( ) ; $ queryParts [ 'page' ] = $ page ; return $ urlBase . '?' . http_build_query ( $ queryParts ) ; } | add the page to the query string create an absolute url |
53,319 | protected function setPageCurrent ( $ page ) { $ page += 0 ; $ page = ( int ) $ page ; $ page = $ page ? $ page : 1 ; if ( $ page > $ this -> possiblePages ) { $ page = $ this -> possiblePages ; } $ this -> pageCurrent = $ page ; } | page is set within the constraints of lowest and highest value |
53,320 | public function regex ( ) { $ uri = preg_replace ( '#\(/\)#' , '/?' , $ this -> uri ) ; $ uri = $ this -> capture ( $ uri , '/:(' . self :: ALLOWED_REGEX . ')/' ) ; $ uri = $ this -> capture ( $ uri , '/{(' . self :: ALLOWED_REGEX . ')}/' ) ; return ( string ) '@^' . $ uri . '$@D' ; } | Returns a regular expression pattern from the given URI . |
53,321 | protected function capture ( $ pattern , $ search ) { $ replace = '(?<$1>' . self :: ALLOWED_REGEX . ')' ; return preg_replace ( $ search , $ replace , $ pattern ) ; } | Capture the specified regular expressions . |
53,322 | public function addField ( Field $ field ) { $ name = $ field -> getName ( ) ; if ( array_key_exists ( $ name , $ this -> fields ) ) { throw new DuplicateFieldNameException ( $ name ) ; } $ this -> fields [ $ name ] = $ field ; foreach ( $ field -> getAliases ( ) as $ alias ) { if ( array_key_exists ( $ alias , $ this ... | Define a field |
53,323 | public function removeField ( $ name ) { if ( ( $ field = $ this -> getField ( $ name ) ) === null ) { return false ; } foreach ( $ field -> getAliases ( ) as $ alias ) { unset ( $ this -> fieldAliases [ $ alias ] ) ; } unset ( $ this -> fields [ $ name ] ) ; return true ; } | Remove a field from the collection |
53,324 | public function getField ( $ name ) { if ( array_key_exists ( $ name , $ this -> fields ) ) { return $ this -> fields [ $ name ] ; } else if ( array_key_exists ( $ name , $ this -> fieldAliases ) ) { $ name = $ this -> fieldAliases [ $ name ] ; return $ this -> fields [ $ name ] ; } return null ; } | Get a field instance |
53,325 | public function getFields ( $ visibility = Field :: VISIBILITY_PUBLIC ) { $ ret = [ ] ; foreach ( $ this -> fields as $ name => $ field ) { if ( $ field -> getVisibility ( ) & $ visibility ) { $ ret [ $ name ] = $ field ; } } return $ ret ; } | Get an associative array of the fields in this collection |
53,326 | public function addValues ( array $ fieldValues ) { foreach ( $ fieldValues as $ fieldName => $ values ) { $ values = Arr :: cast ( $ values ) ; if ( null === ( $ field = $ this -> getField ( $ fieldName ) ) ) { $ message = "unknown field" ; $ len = count ( $ values ) ; if ( $ len !== 1 ) { $ message .= " (encountered ... | Add values to the fields in the collection |
53,327 | public function validate ( ) { $ errs = count ( $ this -> errors ) ; $ dataKey = constant ( get_called_class ( ) . "::EVENT_DATA_KEY" ) ; if ( $ this -> beforeValidate ( ) !== true ) { return false ; } foreach ( $ this -> fields as $ field ) { if ( $ field -> validate ( $ this ) === false ) { foreach ( $ field -> getEr... | Validate the all the fields |
53,328 | public function addError ( Error $ error , $ prepend = false ) { if ( $ prepend === true ) { array_unshift ( $ this -> errors , $ error ) ; } else { $ this -> errors [ ] = $ error ; } return count ( $ this -> errors ) ; } | Add a validation error |
53,329 | public function getErrors ( $ name = null ) { if ( $ name === null ) { return $ this -> errors ; } $ ret = [ ] ; foreach ( $ this -> errors as $ error ) { if ( $ error -> getName ( ) === $ name ) { $ ret [ ] = $ error ; } } return $ ret ; } | Get validation errors for one or all fields |
53,330 | public function exportErrors ( ) { $ ret = [ ] ; foreach ( $ this -> errors as $ error ) { $ ret [ ] = $ error -> export ( ) ; } return $ ret ; } | Export validation errors for all fields |
53,331 | public function exportFieldValue ( $ name , $ exportHandler = null ) { if ( ! is_string ( $ name ) ) { throw new InvalidArgumentException ( "invalid value provided for 'name'; " . "expecting a field name as string" ) ; } else if ( ( $ field = $ this -> getField ( $ name ) ) == null ) { throw new UnknownFieldException (... | Convenience method to get a particular field value |
53,332 | public function exportValues ( ) { $ ret = [ ] ; foreach ( $ this -> fields as $ field ) { if ( $ field -> getExportHandler ( ) !== Field :: EXPORT_SKIP ) { $ ret [ $ field -> getName ( ) ] = $ field -> exportValue ( ) ; } } return $ ret ; } | Get all field values using their respective export handlers |
53,333 | private function initializeCredentials ( ) { $ this -> credentials = base64_encode ( sprintf ( '%s:%s' , urlencode ( $ this -> configuration -> getConsumerKey ( ) ) , urlencode ( $ this -> configuration -> getConsumerSecret ( ) ) ) ) ; } | Initializes the bearer token credentials in the expected format |
53,334 | public function getAll ( ) { $ request = new KmbPuppetDb \ Request ( '/fact-names' ) ; $ response = $ this -> getPuppetDbClient ( ) -> send ( $ request ) ; return ( array ) $ response -> getData ( ) ; } | Get all fact names . |
53,335 | protected function getParameter ( $ name ) { if ( $ this -> hasResolver ( ) ) { $ found = $ this -> getResolver ( ) -> get ( $ name ) ; } else { $ parts = explode ( '.' , $ name ) ; $ found = $ this -> parameters ; while ( null !== ( $ part = array_shift ( $ parts ) ) ) { if ( ! isset ( $ found [ $ part ] ) ) { $ found... | Get this paramter s value either a string or an associate array |
53,336 | protected function fixServices ( array & $ definitions ) { foreach ( $ definitions as $ id => $ def ) { if ( is_array ( $ def ) ) { if ( ! isset ( $ def [ 'class' ] ) ) { $ def = [ 'class' => $ def ] ; } elseif ( ! is_array ( $ def [ 'class' ] ) ) { $ def [ 'class' ] = [ $ def [ 'class' ] ] ; } } else { $ def = [ 'clas... | Normalize service definitions |
53,337 | protected function getMySQLqueryType ( $ sQuery ) { $ queryPieces = explode ( ' ' , $ sQuery ) ; $ statementTypes = $ this -> listOfMySQLqueryStatementType ( $ queryPieces [ 0 ] ) ; if ( in_array ( $ queryPieces [ 0 ] , $ statementTypes [ 'keys' ] ) ) { $ type = $ statementTypes [ 'value' ] [ 'Type' ] ; $ ar1 = [ '1st ... | Returns the Query language type by scanning the 1st keyword from a given query |
53,338 | private function listOfMySQLqueryLanguageType ( $ qType ) { $ keyForReturn = 'Type ' . $ qType . ' stands for' ; $ vMap = [ 'DCL' , 'DDL' , 'DML' , 'DQL' , 'DTL' ] ; if ( in_array ( $ qType , $ vMap ) ) { $ valForReturn = $ this -> readTypeFromJsonFile ( 'MySQLiLanguageTypes' ) [ $ qType ] ; return [ $ keyForReturn => ... | Just to keep a list of type of language as array |
53,339 | private function listOfMySQLqueryStatementType ( $ firstKwordWQuery ) { $ statmentsArray = $ this -> readTypeFromJsonFile ( 'MySQLiStatementTypes' ) ; return [ 'keys' => array_keys ( $ statmentsArray ) , 'value' => [ 'Description' => $ statmentsArray [ $ firstKwordWQuery ] [ 1 ] , 'Type' => $ statmentsArray [ $ firstKw... | Just to keep a list of statement types as array |
53,340 | public function add ( $ oEntity ) { $ this -> checkClass ( $ oEntity ) ; $ this -> values [ $ oEntity -> getCollectionIndex ( ) ] = $ oEntity ; return $ this ; } | Add Entity to collection |
53,341 | protected function indexEntities ( array $ aEntities ) { $ aIndexEntities = array ( ) ; foreach ( $ aEntities as $ oEntity ) { $ aIndexEntities [ $ oEntity -> getCollectionIndex ( ) ] = $ oEntity ; } return $ aIndexEntities ; } | Create index array |
53,342 | protected function determineFeedType ( ) { $ feedType = strtolower ( $ this -> getRoutedParameter ( 'feedType' , static :: TYPE_JSON ) ) ; if ( $ feedType == static :: TYPE_JSON ) { $ this -> displayResolver = static :: RESOLVER_JSON ; if ( empty ( $ this -> callback ) ) { $ this -> contentType = static :: CONTENT_TYPE... | Determine feed type |
53,343 | public static function getWriters ( ) { if ( is_null ( self :: $ _writers ) ) { $ writers = Config :: getInstance ( "JooS_Log" ) -> writers ; if ( ! is_null ( $ writers ) ) { foreach ( $ writers -> valueOf ( ) as $ name ) { $ name = ucfirst ( strtolower ( $ name ) ) ; $ className = Loader :: getClassName ( __NAMESPACE_... | Return log writers |
53,344 | public static function addWriter ( Log_Interface $ writer ) { if ( is_null ( self :: $ _writers ) ) { self :: $ _writers = array ( ) ; } $ key = get_class ( $ writer ) ; if ( ! isset ( self :: $ _writers [ $ key ] ) ) { self :: $ _writers [ $ key ] = $ writer ; $ result = true ; } else { $ result = false ; } return $ r... | Add new writer |
53,345 | public function action ( $ name ) { $ command = '\\App\\Consoles\\' . ucfirst ( $ name ) . 'ConsoleCommand' ; $ command = class_exists ( $ command ) ? $ command : '\\Micro\\Cli\\Consoles\\' . ucfirst ( $ name ) . 'ConsoleCommand' ; if ( ! class_exists ( $ command ) ) { throw new Exception ( 'Command `' . $ name . '` no... | Run action of console command by name |
53,346 | public function regenerateUsernamePasswordTokenWithRoles ( array $ roles , $ mergeWithExistingRoles = true ) { $ user = $ this -> token -> getUser ( ) ; $ credentials = $ this -> token -> getCredentials ( ) ; $ providerKey = $ this -> token -> getProviderKey ( ) ; if ( $ mergeWithExistingRoles ) { $ roles = array_merge... | Regenerate same instance of this token with another roles |
53,347 | public function canSeePv ( $ gid = null ) { $ result = false ; if ( is_null ( $ gid ) ) { $ gid = $ this -> session -> getCustomerGroupId ( ) ; } if ( ! isset ( $ this -> cacheCanSeeByGid [ $ gid ] ) ) { $ item = $ this -> daoPvCustGroup -> getById ( $ gid ) ; if ( $ item ) $ result = ( bool ) $ item -> getCanSeePv ( )... | Cached accessor for Can See PV flag . |
53,348 | public function makeLinks ( $ text ) { $ pattern = '~(?xi) (?: ((ht|f)tps?://) # scheme:// | # or www\d{0,3}\. # "www.", "www1.", "www2." ... "www999." | ... | Make the links clickable . |
53,349 | public function makeHTML ( $ text ) { $ html = $ text ; if ( $ this -> defaultActions [ 'makeLinks' ] ) { $ html = $ this -> makeLinks ( $ html ) ; } if ( $ this -> defaultActions [ 'convertLineEndings' ] ) { $ html = $ this -> convertLineEndings ( $ html ) ; } return $ html ; } | The main function to use instead of calling everything individually . |
53,350 | public function generateTag ( $ tag , $ attributes , $ closeTag = true ) { $ openPattern = replace_variables ( $ this -> openTagPattern , compact ( 'tag' ) ) ; $ external = '' ; if ( in_array ( $ tag , $ this -> voidTags ) && ! empty ( $ this -> voidTagPattern ) && $ this -> voidTagPattern != $ this -> openTagPattern )... | Generate an HTML tag . |
53,351 | public function closeTag ( $ tag ) { if ( ! in_array ( $ tag , $ this -> voidTags ) ) { return replace_variables ( $ this -> closeTagPattern , compact ( 'tag' ) ) ; } return '' ; } | Close an HTML tag . |
53,352 | public function setCachingHeaders ( $ intervalString = CachableBaseComponent :: DEFAULT_MAXAGE ) { $ expires = new \ DateTime ( ) ; $ interval = new \ DateInterval ( $ intervalString ) ; $ maxAge = date_create ( '@0' ) -> add ( $ interval ) -> getTimestamp ( ) ; $ expires = $ expires -> add ( $ interval ) ; ResponseHea... | Set the default caching of pages |
53,353 | public function setNotCachingHeaders ( ) { ResponseHeaders :: add ( ResponseHeaders :: HEADER_CACHE_CONTROL , ResponseHeaders :: HEADER_CACHE_CONTROL_CONTENT_NO_STORE_NO_CACHE_MUST_REVALIDATE_MAX_AGE_0 ) ; ResponseHeaders :: add ( ResponseHeaders :: HEADER_PRAGMA , ResponseHeaders :: HEADER_PRAGMA_CONTENT_NO_CACHE ) ; ... | Set non caching |
53,354 | public function tokenize ( $ input ) { $ tokens = [ ] ; $ exp = ltrim ( $ input ) ; for ( $ length = strlen ( $ exp ) , $ i = 0 ; $ i < $ length ; $ i ++ ) { if ( trim ( $ exp [ $ i ] ) == '' ) { continue ; } if ( NULL !== ( $ token = $ this -> getTerminalToken ( $ exp , $ i ) ) ) { $ tokens [ ] = $ token ; continue ; ... | Tokenize the given source string into annotation tokens and returns the created token sequence . |
53,355 | protected function getStringToken ( $ exp , $ length , & $ i ) { if ( $ exp [ $ i ] == '"' || $ exp [ $ i ] == "'" ) { $ delim = $ exp [ $ i ++ ] ; $ buffer = '' ; $ terminated = false ; $ escaped = false ; for ( ; $ i < $ length ; $ i ++ ) { if ( $ exp [ $ i ] == '\\' ) { $ escaped = ! $ escaped ; } elseif ( $ exp [ $... | Reads a string token from the source expression . |
53,356 | protected function getIntegerToken ( array $ m ) { $ sign = ( isset ( $ m [ 'sign' ] ) && $ m [ 'sign' ] == '-' ) ? - 1 : 1 ; if ( isset ( $ m [ 'oct' ] ) && $ m [ 'oct' ] != '' ) { return new AnnotationToken ( AnnotationToken :: T_INTEGER , $ sign * intval ( $ m [ 'oct' ] , 8 ) ) ; } if ( isset ( $ m [ 'bin' ] ) && $ ... | Builds an integer token from the given match of PATTERN_INTEGER . |
53,357 | public function registerLogger ( LoggerInterface $ logger = null , $ debug = false ) { $ this -> logger = $ logger ? : new NullLogger ( ) ; $ this -> debug = $ debug ; return $ this ; } | register a logger and eventually debug mode into Loggable class |
53,358 | public function insert ( $ fields ) { $ _tmp_fields = [ ] ; $ _tmp_values = [ ] ; if ( is_array ( $ fields ) ) { foreach ( $ fields as $ key => $ value ) { array_push ( $ _tmp_fields , $ key ) ; if ( is_string ( $ value ) ) { array_push ( $ _tmp_values , '\'' . addslashes ( $ value ) . '\'' ) ; } else { array_push ( $ ... | Insert data to table |
53,359 | public function update ( $ fields ) { if ( is_array ( $ fields ) ) { foreach ( $ fields as $ key => $ value ) { if ( is_string ( $ value ) ) { array_push ( $ this -> _updates , $ key . ' = \'' . addslashes ( $ value ) . '\'' ) ; } else { array_push ( $ this -> _updates , $ key . ' = ' . $ value ) ; } } } else { return ... | Update data from table |
53,360 | public function asc ( $ fields ) { if ( is_array ( $ fields ) ) { $ this -> _order = ' ORDER BY ' . implode ( $ fields , ', ' ) . ' ASC' ; } else { $ this -> _order = ' ORDER BY ' . $ fields . ' ASC' ; } return $ this ; } | Order by ascending |
53,361 | public function desc ( $ fields ) { if ( is_array ( $ fields ) ) { $ this -> _order = ' ORDER BY ' . implode ( $ fields , ', ' ) . ' DESC' ; } else { $ this -> _order = ' ORDER BY ' . $ fields . ' DESC' ; } return $ this ; } | Order by descending |
53,362 | public function leftJoin ( $ table , $ field1 , $ operator , $ field2 ) { array_push ( $ this -> _joins , ' LEFT JOIN ' . $ table . ' ON ' . $ field1 . ' ' . $ operator . ' ' . $ field2 . ' ' ) ; return $ this ; } | Left Join Tables |
53,363 | public function rightJoin ( $ table , $ field1 , $ operator , $ field2 ) { array_push ( $ this -> _joins , ' RIGHT JOIN ' . $ table . ' ON ' . $ field1 . ' ' . $ operator . ' ' . $ field2 . ' ' ) ; return $ this ; } | Right Join Tables |
53,364 | private function AddSitemapActiveField ( ) { $ name = 'SitemapActive' ; $ field = new Checkbox ( $ name ) ; if ( ! $ this -> site -> Exists ( ) || $ this -> site -> GetSitemapActive ( ) ) { $ field -> SetChecked ( ) ; } $ this -> AddField ( $ field ) ; } | Adds the sitemap active checkbox |
53,365 | protected function OnSuccess ( ) { $ action = Action :: Update ( ) ; if ( ! $ this -> site -> Exists ( ) ) { $ action = Action :: Create ( ) ; $ this -> site -> SetUser ( self :: Guard ( ) -> GetUser ( ) ) ; } $ this -> site -> SetName ( $ this -> Value ( 'Name' ) ) ; $ this -> site -> SetUrl ( $ this -> Value ( 'Url' ... | Saves the site |
53,366 | public function get ( ? string $ index , string $ text , ? array $ params = null ) { if ( App :: $ Request -> getLanguage ( ) !== App :: $ Properties -> get ( 'baseLanguage' ) ) { if ( $ index && ! Arr :: in ( $ index , $ this -> indexes ) ) { $ this -> cached = Arr :: merge ( $ this -> cached , $ this -> load ( $ inde... | Get internalization of current text from i18n |
53,367 | public function translate ( string $ text , array $ params = null ) { $ index = null ; $ namespace = 'Apps\Controller\\' . env_name . '\\' ; foreach ( @ debug_backtrace ( ) as $ caller ) { if ( isset ( $ caller [ 'class' ] ) && Str :: startsWith ( $ namespace , $ caller [ 'class' ] ) ) { $ index = Str :: sub ( ( string... | Get internalization based on called controller |
53,368 | protected function load ( string $ index ) : ? array { $ file = root . '/I18n/' . env_name . '/' . App :: $ Request -> getLanguage ( ) . '/' . $ index . '.php' ; if ( ! File :: exist ( $ file ) ) { return [ ] ; } return require ( $ file ) ; } | Load locale file from local storage |
53,369 | public function append ( $ path ) : bool { $ path = Normalize :: diskFullPath ( $ path ) ; if ( ! File :: exist ( $ path ) ) { return false ; } $ addTranslation = require ( $ path ) ; if ( ! Any :: isArray ( $ addTranslation ) ) { return false ; } $ this -> cached = Arr :: merge ( $ this -> cached , $ addTranslation ) ... | Append translation data from exist full path |
53,370 | public function getAvailableLangs ( ) : array { $ langs = [ 'en' ] ; $ scan = Directory :: scan ( root . '/I18n/' . env_name . '/' , GLOB_ONLYDIR , true ) ; foreach ( $ scan as $ row ) { $ langs [ ] = trim ( $ row , '/' ) ; } return $ langs ; } | Get available languages in the filesystem |
53,371 | public function getLocaleText ( $ input , ? string $ lang = null , ? string $ default = null ) : ? string { if ( $ lang === null ) { $ lang = App :: $ Request -> getLanguage ( ) ; } if ( Any :: isStr ( $ input ) ) { $ input = Serialize :: decode ( $ input ) ; } if ( Any :: isArray ( $ input ) && array_key_exists ( $ la... | Get locale data from input array or serialized string |
53,372 | public function getDate ( $ format = null ) { $ format = empty ( $ format ) ? $ this -> format : $ format ; return strftime ( $ format , $ this -> ts ) ; } | Retorna data no formato especificado |
53,373 | public function unlock ( ) { $ this -> count -- ; if ( $ this -> count < 0 ) { $ this -> count = 0 ; return false ; } if ( 0 === $ this -> count ) { $ this -> entityManager -> flush ( ) ; return true ; } return false ; } | Call this at the end of a persistence function . |
53,374 | public static function getCurrent ( $ navigation , $ current ) { self :: iterateItems ( $ navigation ) ; foreach ( self :: $ navItem as $ item ) { if ( $ item === $ current ) { self :: getCurrentItem ( intval ( floor ( self :: $ navItem -> getDepth ( ) / 2 ) ) ) ; } } ksort ( self :: $ currentItems ) ; return self :: $... | Creates the current menu items which are selected from the navigation item hierarchy |
53,375 | protected static function getCurrentItem ( $ depth ) { self :: $ currentItems [ $ depth ] = iterator_to_array ( self :: $ navItem -> getSubIterator ( ( ( $ depth * 2 ) + 1 ) ) ) ; unset ( self :: $ currentItems [ $ depth ] [ 'children' ] ) ; if ( $ depth >= 1 ) { self :: getCurrentItem ( ( $ depth - 1 ) ) ; } } | Gets the current level items from the menu array |
53,376 | final protected function parseSimpleXML ( \ SimpleXMLElement $ element ) { $ elements = [ ] ; foreach ( $ element -> attributes ( ) as $ attribute => $ value ) { $ elements [ $ attribute ] = $ value instanceof \ SimpleXMLElement ? $ this -> parseSimpleXML ( $ value ) : $ value ; } foreach ( $ element -> children ( ) as... | Parse xml to array . |
53,377 | private function getTypedValue ( string $ value ) { if ( \ in_array ( $ value , self :: $ boolValues , true ) ) { return \ in_array ( $ value , self :: $ truthlyValues , true ) ; } if ( \ is_numeric ( $ value ) ) { return $ this -> getNumericValue ( $ value ) ; } return $ value ; } | Transforms string to type . |
53,378 | private function getNumericValue ( string $ value ) { if ( \ strpos ( $ value , '.' ) !== false ) { return ( float ) $ value ; } return ( int ) $ value ; } | Get numeric value from string . |
53,379 | public function cakephpPlugins ( $ opts = [ 'format' => 'table' , 'fields' => '' ] ) { $ result = $ this -> taskCakephpPlugins ( ) -> run ( ) ; if ( ! $ result -> wasSuccessful ( ) ) { $ this -> exitError ( "Failed to run the command" ) ; } return new PropertyList ( $ result -> getData ( ) [ 'data' ] ) ; } | List CakePHP loaded plugins |
53,380 | final public function check ( array $ options ) { foreach ( $ options as $ property => $ value ) { if ( ( is_array ( $ value ) && ! in_array ( $ this -> $ property , $ value ) ) || ( ! is_array ( $ value ) && $ this -> $ property !== $ value ) ) return false ; } return true ; } | Checks if properties exist and their values are as required |
53,381 | private function getPostsPermissions ( ) { return [ [ 'name' => 'Posts - List all posts' , 'description' => 'Allow to list all posts.' , 'slug' => PostsPolicy :: PERMISSION_LIST , ] , [ 'name' => 'Posts - View a post' , 'description' => 'Allow to display a post.' , 'slug' => PostsPolicy :: PERMISSION_SHOW , ] , [ 'name... | Get the Posts permissions . |
53,382 | private function getCategoriesPermissions ( ) { return [ [ 'name' => 'Categories - List all categories' , 'description' => 'Allow to list all categories.' , 'slug' => CategoriesPolicy :: PERMISSION_LIST , ] , [ 'name' => 'Categories - View a category' , 'description' => 'Allow to display a category.' , 'slug' => Catego... | Get the Categories permissions . |
53,383 | private function getTagsPermissions ( ) { return [ [ 'name' => 'Tags - List all tags' , 'description' => 'Allow to list all tags.' , 'slug' => TagsPolicy :: PERMISSION_LIST , ] , [ 'name' => 'Tags - View a tag' , 'description' => 'Allow to display a tag.' , 'slug' => TagsPolicy :: PERMISSION_SHOW , ] , [ 'name' => 'Tag... | Get the Tags permissions . |
53,384 | private function getFilters ( ) { $ filters = new Collection ; foreach ( $ this -> getCachedPermissionGroups ( ) as $ group ) { $ filters -> push ( [ 'name' => $ group -> name , 'params' => [ $ group -> hashed_id ] , ] ) ; } if ( Permission :: where ( 'group_id' , 0 ) -> count ( ) ) { $ filters -> push ( [ 'name' => tr... | Get the groups filters data . |
53,385 | public function render ( array $ options = [ ] ) : string { $ this -> resolveOptions ( $ options ) ; if ( false === $ this -> validate ( ) ) { return false ; } $ this -> splitCellsContent ( ) ; $ this -> calculateSizes ( ) ; $ this -> tableWidth = $ this -> calculateTableWidth ( ) ; $ table = $ this -> options [ 'has_h... | Renders the table as plain text . |
53,386 | public function validate ( ) : bool { $ numberOfColumns = null ; $ this -> errors = [ ] ; if ( 0 >= count ( $ this -> data ) ) { $ message = 'There are no rows in the table' ; $ this -> errors [ ] = $ message ; return false ; } foreach ( $ this -> data as $ row ) { $ found = count ( $ row ) ; if ( null === $ numberOfCo... | Validates the given array to check all the rows have the same number of columns . |
53,387 | private function splitCellsContent ( ) { foreach ( $ this -> data as $ rowPosition => $ rowContent ) { foreach ( $ rowContent as $ columnName => $ cellContent ) { $ cellContent = $ this -> reduceSpaces ( $ cellContent ) ; if ( false === isset ( $ this -> options [ 'columns' ] [ $ columnName ] [ 'max_width' ] ) ) { $ th... | Splits the content of each cell into multiple lines according to the set max column width . |
53,388 | private function calculateSizes ( ) { foreach ( $ this -> data as $ rowPosition => $ rowContent ) { foreach ( $ rowContent as $ columnName => $ cellContent ) { if ( false === isset ( $ this -> rowsHeights [ $ rowPosition ] ) ) { $ this -> rowsHeights [ $ rowPosition ] = count ( $ cellContent ) ; } if ( isset ( $ this -... | Calculates the width of each column of the table . |
53,389 | private function calculateTableWidth ( ) : int { $ tableWidth = 0 ; foreach ( $ this -> columnsWidths as $ width ) { $ tableWidth += $ width ; } $ tableWidth += 1 ; $ tableWidth += ( $ this -> options [ 'cells_padding' ] [ 1 ] + $ this -> options [ 'cells_padding' ] [ 3 ] ) * count ( $ this -> columnsWidths ) ; $ table... | Calculates the total width of the table . |
53,390 | private function drawDivider ( string $ prefix = 'sep_' ) : string { $ divider = '' ; foreach ( $ this -> columnsWidths as $ width ) { $ times = $ width + $ this -> options [ 'cells_padding' ] [ 1 ] + $ this -> options [ 'cells_padding' ] [ 3 ] ; $ divider .= $ this -> options [ $ prefix . 'x' ] . $ this -> repeatChar ... | Draws the horizontal divider . |
53,391 | private function resolveCellsPaddings ( ) : array { $ return = [ 0 , 0 , 0 , 0 ] ; if ( false === isset ( $ this -> options [ 'cells_padding' ] ) ) { return $ return ; } $ resolver = new OptionsResolver ( ) ; $ resolver -> setDefined ( 0 ) ; $ resolver -> setDefined ( 1 ) ; $ resolver -> setDefined ( 2 ) ; $ resolver -... | Set the padding of the cells . |
53,392 | public function sendMessage ( $ level , $ message ) { $ this -> db -> insert ( $ this -> tableName , [ 'level' => $ level , 'message' => $ message , 'date_create' => $ _SERVER [ 'REQUEST_TIME' ] ] ) ; } | Send log message into DB |
53,393 | public function count ( array $ constraints = [ ] , QueryBuilder $ qb = null ) { $ qb = ! is_null ( $ qb ) ? $ qb : $ this -> createQueryBuilder ( 'e' ) ; if ( count ( $ constraints ) ) $ qb = $ this -> _by ( $ qb , $ constraints ) ; return $ this -> arrange ( $ this -> _count ( $ qb ) , Repository :: RESULT_SHAPE_SCAL... | Return number of entities |
53,394 | protected function _paginate ( QueryBuilder $ qb , int $ offset , int $ limit ) { return $ qb -> setFirstResult ( $ offset ) -> setMaxResults ( $ limit ) ; } | Improve QueryBuilder with basic paginate request |
53,395 | public static function init ( Container $ container = null ) { if ( empty ( self :: $ _instance ) ) { if ( version_compare ( PHP_VERSION , '5.6.0' , '<' ) ) { throw new \ ErrorException ( 'NONSUPPORT_PHP_VERSION' ) ; } if ( is_null ( $ container ) ) { $ container = Container :: instance ( ) ; } self :: $ _instance = ne... | Initialize the server object . |
53,396 | public function registerRouter ( $ router , ... $ params ) { $ this -> _router -> add ( $ router , ... $ params ) ; if ( defined ( 'FOCUS_DEBUG' ) && FOCUS_DEBUG ) { $ this -> getLogger ( ) -> debug ( 'add new router: ' . ( is_string ( $ router ) ? $ router : get_class ( $ router ) ) ) ; } } | register router . |
53,397 | public function registerAutoloader ( $ baseDir , $ baseNs ) { $ baseNs = $ baseNs [ strlen ( $ baseNs ) - 1 ] == '\\' ? $ baseNs : "{$baseNs}\\" ; $ baseDir = rtrim ( $ baseDir , '/' ) ; spl_autoload_register ( function ( $ class ) use ( $ baseDir , $ baseNs ) { if ( strncmp ( $ baseNs , $ class , strlen ( $ baseNs ) )... | register class autoloader . |
53,398 | public function load ( $ key ) { $ data = $ this -> adapter -> getItem ( $ key , $ success ) ; if ( $ success && $ this -> automaticSerialization ) { $ data = unserialize ( $ data ) ; if ( $ data === false ) { $ this -> remove ( $ key ) ; } } return $ data ; } | Get an item |
53,399 | public static function isValid ( $ token ) { $ expiration = Config :: get ( 'security.anti_csrf.expiration' , 18000 ) ; $ computed = microtime ( true ) - ( double ) Text :: unlock ( $ token , self :: getKey ( ) ) ; return $ computed <= $ expiration ; } | Check Validity of Token |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.