idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
233,300 | public function getFileFromString ( $ string , $ directory , $ extensions = array ( ) ) : string { $ directory = preg_replace ( '#/+#' , '/' , ( ! is_null ( $ directory ) ? $ directory : $ this -> directory ) . DS ) ; if ( strpbrk ( $ directory , "\\/?%*:|\"<>" ) === TRUE || strpbrk ( $ string , "\\/?%*:|\"<>" ) === TR... | Converts a layout string to a file using the directory and the used extensions . |
233,301 | public function setFileFromString ( $ string , $ directory , $ extensions = array ( ) ) { $ this -> file = $ this -> getFileFromString ( $ string , $ directory , $ extensions ) ; $ this -> directory = preg_replace ( '#/+#' , '/' , ( ! is_null ( $ directory ) ? $ directory : $ this -> directory ) . DS ) ; } | Converts a layout string to a file using the directory and the used extensions . It also sets the file variable of this class . |
233,302 | public function setEngine ( $ name ) : bool { $ this -> loadTemplateEngines ( ) ; if ( isset ( $ this -> engines [ $ name ] ) ) { $ this -> current_engine = $ this -> engines [ $ name ] ; Logger :: log ( 'Set the Template Engine to ' . $ name ) ; return true ; } throw new LayoutException ( 'Could not set engine. Engine... | Set the engine for the next layout . |
233,303 | public function getEngine ( $ name ) : TemplateEngine { $ this -> loadTemplateEngines ( ) ; if ( isset ( $ this -> engines [ $ name ] ) ) { return $ this -> engines [ $ name ] ; } throw new LayoutException ( 'Could not return engine. Engine does not exist' , 1 ) ; } | Get a loaded template engine . |
233,304 | public function registerEngine ( $ engineClass , $ engineName , $ engineFileExtensions = array ( ) ) : bool { if ( isset ( $ this -> engines [ $ engineName ] ) ) { throw new LayoutException ( "Could not register engine. Engine '" . $ engineName . "' already registered" , 1 ) ; } if ( $ engineClass instanceof TemplateEn... | Register a new template engine . |
233,305 | public function loadTemplateEngines ( ) { if ( ! $ this -> engines_loaded ) { Events :: fireEvent ( 'layoutLoadEngineEvent' ) ; $ this -> registerEngine ( new PHPEngine ( ) , 'PHP' , array ( 'php' ) ) ; $ this -> registerEngine ( new JsonEngine ( ) , 'JSON' , array ( 'json' ) ) ; $ this -> registerEngine ( new SmartyEn... | Load the template engines by sending a layoutLoadEngineEvent . |
233,306 | public function reset ( ) { if ( ! is_null ( $ this -> current_engine ) ) { $ this -> current_engine -> reset ( ) ; } $ this -> engines = array ( ) ; $ this -> engines_loaded = false ; $ this -> file_extensions = array ( ) ; $ this -> current_engine = null ; $ this -> assigned_variables = array ( ) ; $ this -> director... | Resets the layout manager to its default state . |
233,307 | protected function remapPublishStates ( array $ config , ContainerBuilder $ container ) { $ publishStates = array ( ) ; foreach ( $ config as $ role ) { $ publishStates [ $ role [ 'value' ] ] = $ role [ 'name' ] ; } $ container -> setParameter ( 'manhattan.publish.states' , $ publishStates ) ; } | Remaps parsed array for default into Choices field |
233,308 | public function prepend ( ContainerBuilder $ container ) { $ bundles = $ container -> getParameter ( 'kernel.bundles' ) ; if ( isset ( $ bundles [ 'ManhattanPublishBundle' ] ) ) { $ loader = new Loader \ YamlFileLoader ( $ container , new FileLocator ( __DIR__ . '/../Resources/config' ) ) ; $ loader -> load ( 'config.y... | Prepend extension to load in config file |
233,309 | public function redirect ( $ path , $ status = 301 ) { if ( ! $ this -> asWidget ) { $ response = ( new ResponseInjector ) -> build ( ) ; if ( ! $ response ) { throw new Exception ( 'Component `response` not configured' ) ; } $ response = $ response -> withStatus ( $ status ) ; $ response = $ response -> getHeaderLine ... | Redirect user to path |
233,310 | public function params ( $ params ) { if ( false === is_array ( $ params ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type array, "%s" given' , __METHOD__ , gettype ( $ data ) ) , E_USER_ERROR ) ; } $ this -> params = $ params ; return $ this ; } | Set the parameters |
233,311 | public function domain ( $ domain , $ protocol = null ) { if ( false === is_string ( $ domain ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ domain ) ) , E_USER_ERROR ) ; } if ( false === Router :: routeExists ( $ this -> identifier ,... | Set the domain name with HTTP protocol |
233,312 | public function seconds ( $ seconds ) { if ( false === ( '-' . intval ( $ seconds ) == '-' . $ seconds ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ seconds ) ) , E_USER_ERROR ) ; } $ this -> seconds = $ seconds ; return $ this ; } | Set the amount of seconds |
233,313 | public function execute ( $ code = null ) { if ( null !== $ code && false === ( '-' . intval ( $ code ) == '-' . $ code ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type integer, "%s" given' , __METHOD__ , gettype ( $ code ) ) , E_USER_ERROR ) ; } $ this -> setUrl ( ) ; if ( null !==... | Execute forward with options HTTP status code |
233,314 | public function deleteImages ( ) { $ thumb = false ; $ img = false ; if ( file_exists ( $ this -> path ) ) { unlink ( $ this -> path ) ; } if ( file_exists ( $ this -> thumbnailPath ) ) { unlink ( $ this -> thumbnailPath ) ; } $ img = ! file_exists ( $ this -> path ) ; $ thumb = ! file_exists ( $ this -> thumbnailPath ... | Phisically remove images that are related to this doument entity . It does not touch anything on the database! |
233,315 | private function parseFileToDOM ( $ file ) { try { $ dom = XmlUtils :: loadFile ( $ file , array ( $ this , 'validateSchema' ) ) ; } catch ( \ InvalidArgumentException $ e ) { throw new InvalidArgumentException ( sprintf ( 'Unable to parse file "%s".' , $ file ) , $ e -> getCode ( ) , $ e ) ; } $ this -> validateExtens... | Parses a XML file to a \ DOMDocument . |
233,316 | private function validateExtensions ( \ DOMDocument $ dom , $ file ) { foreach ( $ dom -> documentElement -> childNodes as $ node ) { if ( ! $ node instanceof \ DOMElement || 'http://symfony.com/schema/dic/services' === $ node -> namespaceURI ) { continue ; } if ( ! $ this -> container -> hasExtension ( $ node -> names... | Validates an extension . |
233,317 | private function loadFromExtensions ( \ DOMDocument $ xml ) { foreach ( $ xml -> documentElement -> childNodes as $ node ) { if ( ! $ node instanceof \ DOMElement || self :: NS === $ node -> namespaceURI ) { continue ; } $ values = static :: convertDomElementToArray ( $ node ) ; if ( ! is_array ( $ values ) ) { $ value... | Loads from an extension . |
233,318 | public function setScope ( $ scope ) { if ( in_array ( $ scope , $ this -> scopes ) === false ) { throw Exception \ Scope :: invalidScope ( $ scope , $ this -> scopes ) ; } $ this -> scope = $ scope ; return $ this ; } | Set the current scope |
233,319 | public function parseBlockComment ( $ blockComment ) { $ blockCommentLines = $ this -> parseBlockCommentLines ( $ blockComment ) ; return new Element \ DocumentationBlock ( $ this -> parseBlockCommentTags ( $ blockCommentLines ) , $ this -> parseBlockCommentSummary ( $ blockCommentLines ) , $ this -> parseBlockCommentB... | Parse a documentation block comment . |
233,320 | public function value ( $ value ) { if ( ! is_array ( $ value ) ) { if ( strpbrk ( $ value , Lexer :: ESCAPED_STRING ) !== false ) { if ( ! ( substr ( $ value , 0 , 1 ) == '"' && substr ( $ value , - 1 ) == '"' ) ) { return '(' . addcslashes ( $ value , Lexer :: ESCAPED_STRING_PAREN_ENCAPSED ) . ')' ; } } return $ valu... | Compile a value |
233,321 | public function isAnInExpression ( TreeExpression $ expr ) { $ count = $ expr -> count ( ) ; if ( $ count <= 1 || strtolower ( $ expr -> getValue ( ) ) != 'or' ) return false ; $ children = $ expr -> getChildren ( ) ; if ( ! $ children [ 0 ] instanceof FieldExpression ) return false ; for ( $ i = 1 ; $ i < $ count ; $ ... | Can be the tree expression converted in a FIELD IN ... expression? |
233,322 | static function xmlData ( $ string , $ cdata = false ) { $ string = str_replace ( "]]>" , "]]]]><![CDATA[>" , $ string ) ; if ( ! $ cdata ) $ string = "<![CDATA[$string]]>" ; return $ string ; } | Normalize the string for XML tag content data |
233,323 | static function compressCSS ( $ code ) { $ code = self :: clearWhitespaces ( $ code ) ; $ code = preg_replace ( '/ ?\{ ?/' , "{" , $ code ) ; $ code = preg_replace ( '/ ?\} ?/' , "}" , $ code ) ; $ code = preg_replace ( '/ ?\; ?/' , ";" , $ code ) ; $ code = preg_replace ( '/ ?\> ?/' , ">" , $ code ) ; $ code = preg_re... | Returns compressed content of given CSS code |
233,324 | public function putErrors ( $ errors ) { if ( ! is_array ( $ errors ) && ! ( $ errors instanceof MessageProvider ) ) { $ errors = [ $ errors ] ; } $ this -> errors -> merge ( $ errors ) ; } | Puts more errors in its message bag . |
233,325 | public function syncAction ( ) { $ this -> manager -> syncPackages ( PackageHelperInterface :: DEFAULT_PACKAGE_BUNDLE_TYPE ) ; $ this -> manager -> syncPackages ( PackageHelperInterface :: DEFAULT_PACKAGE_THEME_TYPE ) ; $ this -> manager -> getFlashHelper ( ) -> addSuccess ( 'package.flash.sync.success' ) ; return $ th... | Action used to sync packages from remote servers ie . packagist . org |
233,326 | public function notifyAction ( Request $ request ) { $ token = $ this -> getHttpRequestVerifier ( ) -> verify ( $ request ) ; $ gateway = $ this -> getPayum ( ) -> getGateway ( $ token -> getGatewayName ( ) ) ; $ gateway -> execute ( $ notify = new Notify ( $ token ) ) ; $ payment = $ notify -> getFirstModel ( ) ; $ ev... | Notify action . |
233,327 | public function doneAction ( Request $ request ) { $ debug = $ this -> container -> getParameter ( 'kernel.debug' ) ; $ token = $ this -> getHttpRequestVerifier ( ) -> verify ( $ request ) ; $ gateway = $ this -> getPayum ( ) -> getGateway ( $ token -> getGatewayName ( ) ) ; $ gateway -> execute ( $ done = new Done ( $... | Done action . |
233,328 | public function add ( TrackedObject $ tracked ) { $ id = $ tracked -> getID ( ) ; if ( isset ( $ this -> map [ $ id ] ) ) { return ; } $ this -> map [ $ id ] = $ tracked ; $ this -> adapter -> watch ( $ tracked ) ; } | Add a new TrackedObject into map |
233,329 | public function addChangeSet ( $ tracked , $ eventMask ) { if ( $ tracked instanceof TrackedObject ) { $ path = $ tracked -> getResource ( ) ; if ( $ this -> fileOnly && ! $ tracked -> getResource ( ) instanceof FileResource ) { return ; } } else { $ path = $ tracked ; } $ event = new FilesystemEvent ( $ path , $ event... | Add a new event to changeset |
233,330 | private function scanDir ( $ path ) { if ( ! is_dir ( $ path ) ) return ; $ finder = $ this -> createFinder ( ) ; $ rootSPL = new DirectoryResource ( $ path ) ; $ rootResource = new DirectoryResource ( $ rootSPL ) ; $ rootResource = $ this -> createTrackedObject ( $ rootResource ) ; $ this -> add ( $ rootResource ) ; f... | Scan path and add it to listener |
233,331 | public function createTrackedObject ( ResourceInterface $ resource ) { $ tracked = new TrackedObject ( ) ; $ tracked -> setResource ( $ resource ) ; $ tracked -> setChecksum ( $ resource -> getChecksum ( ) ) ; if ( is_null ( $ tracked -> getID ( ) ) ) { $ tracked -> setID ( PathUtil :: createPathID ( $ resource -> getR... | Create new TrackedObject |
233,332 | protected function create ( Request $ request ) : Model { return User :: create ( [ 'name' => $ request -> input ( 'name' ) , 'email' => $ request -> input ( 'email' ) , 'password' => Hash :: make ( $ request -> input ( 'password' ) ) ] ) ; } | Add new a new user |
233,333 | public function chain ( Reader $ reader ) { $ newFilter = new LocalConfigurationFilter ( $ reader ) ; $ newFilter -> setProject ( $ this -> getProject ( ) ) ; $ newFilter -> setCacheDir ( $ this -> getCacheDir ( ) ) ; $ newFilter -> setTYPO3Version ( $ this -> getTYPO3Version ( ) ) ; $ newFilter -> addInstallTool ( $ t... | Creates a new LocalConfigurationFilter using the passed in Reader for instantiation . |
233,334 | public function read ( $ len = null ) { if ( FALSE === $ this -> getInitialized ( ) ) { $ this -> initialize ( ) ; $ this -> setInitialized ( TRUE ) ; } $ defaultConfiguration = '' ; if ( - 1 === version_compare ( $ this -> getTYPO3Version ( ) , '0.0.0' ) ) { throw new BuildException ( 'You must pass a TYPO3 version vi... | Reads stream applies property file formatting and returns resulting stream . |
233,335 | private function initialize ( ) { $ params = $ this -> getParameters ( ) ; if ( $ params ) { foreach ( $ params as $ param ) { $ setter = 'set' . str_replace ( ' ' , '' , ucwords ( str_replace ( '-' , ' ' , $ param -> getName ( ) ) ) ) ; if ( FALSE === method_exists ( $ this , $ setter ) ) { $ msg = sprintf ( 'Unknown ... | Initializes any parameters |
233,336 | protected function setDefaultConfiguration ( $ rawContent ) { $ resolvedContent = strtr ( $ rawContent , $ this -> unresolveableReplacementPairs ) ; $ cacheFile = tempnam ( $ this -> cacheDir , 'tmp' ) ; $ fh = fopen ( $ cacheFile , 'w' ) ; fwrite ( $ fh , $ resolvedContent ) ; fclose ( $ fh ) ; $ this -> defaultConfig... | modifies the given raw content by creating a temp file and resolving some TYPO3 CMS constants |
233,337 | public function createPropertyPathsFromCommentArray ( $ comments ) { $ out = '' ; foreach ( $ comments as $ mainKey => $ subKeys ) { foreach ( $ subKeys as $ subKey => $ comment ) { if ( '' === $ comment ) { continue ; } $ defaultConfigurationValue = $ this -> defaultConfiguration [ $ mainKey ] [ $ subKey ] ; if ( FALS... | creates the property file lines for the given comments array |
233,338 | public function toArray ( $ keys = array ( ) ) { $ vars = get_object_vars ( $ this ) ; $ results = array ( ) ; if ( count ( $ keys ) == 0 ) { foreach ( $ vars as $ name => $ value ) { if ( is_string ( $ value ) || is_numeric ( $ value ) || is_bool ( $ value ) ) { $ results [ $ name ] = $ value ; } } return $ results ; ... | Serializes an object into a dictionary |
233,339 | static function json ( $ data , $ code = 200 ) { return ( new Response ( ) ) -> setCode ( $ code ) -> setContent ( json_encode ( $ data ) ) -> setContentType ( 'application/json' ) ; } | Create Response object with JSON header + content |
233,340 | function setCode ( $ code ) { $ this -> code = $ code ; $ this -> addHeader ( $ this -> getDefaultHeaderFromCode ( $ code ) ) ; return $ this ; } | Set HTTP code and put on header |
233,341 | final public function openFile ( $ filename , $ use_include_path = false ) { $ this -> getPathInfo ( $ filename , $ use_include_path ) ; $ this -> fileResource = fopen ( $ this -> dirname . DIRECTORY_SEPARATOR . $ this -> basename , self :: FILE_MODE ) ; return flock ( $ this -> fileResource , LOCK_EX ) ; } | Opens the file in the specified mode designating read write create capabilities . Obtains exclusive lock on file which is released when class is destroyed . |
233,342 | public final function getDifferenceYears ( $ dt = null , bool $ abs = true ) : int { $ dt = $ dt ? : static :: Now ( $ this -> getTimezone ( ) ) ; return ( int ) $ this -> diff ( $ dt , $ abs ) -> format ( '%r%y' ) ; } | Get the difference in years between current date time and defined . |
233,343 | public function setISODate ( $ year , $ week , $ day = null ) : DateTime { parent :: setISODate ( $ year , $ week , $ day ) ; return $ this ; } | Sets a date by ISO - 8601 conform data . |
233,344 | public final function setYear ( int $ year = null ) : DateTime { if ( \ is_null ( $ year ) ) { $ year = static :: CurrentYear ( ) ; } return $ this -> setDateParts ( $ year ) ; } | Changes the current defined year to defined value . |
233,345 | public final function setMonth ( int $ month = null ) : DateTime { if ( \ is_null ( $ month ) ) { $ month = static :: CurrentMonth ( ) ; } return $ this -> setDateParts ( null , $ month ) ; } | Changes the current defined month to defined value . |
233,346 | public final function setDay ( int $ day = null ) : DateTime { if ( \ is_null ( $ day ) ) { $ day = static :: CurrentDay ( ) ; } return $ this -> setDateParts ( null , null , $ day ) ; } | Changes the current defined day to defined value . |
233,347 | public final function setHour ( int $ hour = null ) : DateTime { if ( \ is_null ( $ hour ) ) { $ hour = static :: CurrentHour ( ) ; } return $ this -> setTimeParts ( $ hour ) ; } | Changes the current defined hour to defined value . |
233,348 | public final function setMinute ( int $ minute = null ) : DateTime { if ( \ is_null ( $ minute ) ) { $ minute = static :: CurrentMinute ( ) ; } return $ this -> setTimeParts ( null , $ minute ) ; } | Changes the current defined minute to defined value . |
233,349 | public final function setSecond ( int $ second = null ) : DateTime { if ( \ is_null ( $ second ) ) { $ second = static :: CurrentSecond ( ) ; } return $ this -> setTimeParts ( null , null , $ second ) ; } | Changes the current defined second to defined value . |
233,350 | public final function addSeconds ( int $ seconds = 1 ) : DateTime { return $ this -> move ( new \ DateInterval ( 'PT' . \ abs ( $ seconds ) . 'S' ) , $ seconds < 0 ) ; } | Adds the defined number of seconds . |
233,351 | public final function addMinutes ( int $ minutes = 1 ) : DateTime { return $ this -> move ( new \ DateInterval ( 'PT' . \ abs ( $ minutes ) . 'M' ) , $ minutes < 0 ) ; } | Adds the defined number of minutes . |
233,352 | public final function addHours ( int $ hours = 1 ) : DateTime { return $ this -> move ( new \ DateInterval ( 'PT' . \ abs ( $ hours ) . 'H' ) , $ hours < 0 ) ; } | Adds the defined number of hours . |
233,353 | public final function addDays ( int $ days = 1 ) : DateTime { return $ this -> move ( new \ DateInterval ( 'P' . \ abs ( $ days ) . 'D' ) , $ days < 0 ) ; } | Adds the defined number of days . |
233,354 | public final function addWeeks ( int $ weeks = 1 ) : DateTime { return $ this -> move ( new \ DateInterval ( 'P' . \ abs ( $ weeks ) . 'W' ) , $ weeks < 0 ) ; } | Adds the defined number of weeks . |
233,355 | public final function formatNamedDate ( bool $ short = false ) : string { if ( $ short ) { return \ sprintf ( '%s., %s. %s %d' , $ this -> getShortWeekDayName ( ) , $ this -> getDay ( ) , $ this -> getShortMonthName ( ) , $ this -> getYear ( ) ) ; } return \ sprintf ( '%s, %s. %s %d' , $ this -> getWeekDayName ( ) , $ ... | Formats the current instance to a named date depending to current used locale . The output uses long names like Montag 20 . Dezember 2030 or short names like Mon 20 . Dec 2030 |
233,356 | public static function Parse ( $ datetime , \ DateTimeZone $ timezone = null ) { if ( \ is_null ( $ datetime ) ) { return false ; } if ( $ datetime instanceof DateTime ) { return $ datetime ; } if ( $ datetime instanceof \ DateTimeInterface ) { return new DateTime ( $ datetime -> format ( 'y-m-d H:i:s' ) , $ datetime -... | Parses a value to a \ Beluga \ Date \ DateTime instance . |
233,357 | public static function Create ( int $ year , int $ month , int $ day , int $ hour = 0 , int $ minute = 0 , int $ second = 0 ) : DateTime { $ dt = new DateTime ( ) ; $ dt -> setDate ( $ year , $ month , $ day ) ; $ dt -> setTime ( $ hour , $ minute , $ second ) ; return $ dt ; } | Init s a new instance . |
233,358 | public static function FromDateTime ( \ DateTime $ dt ) : DateTime { if ( $ dt instanceof DateTime ) { return clone $ dt ; } return new DateTime ( $ dt -> format ( 'Y-m-d H:i:s.u' ) , $ dt -> getTimezone ( ) ) ; } | Create a DateTime instance from PHP \ DateTime instance . |
233,359 | public static function FromFormat ( string $ format , $ time , \ DateTimeZone $ timezone = null ) : DateTime { if ( $ timezone !== null ) { $ dt = parent :: createFromFormat ( $ format , $ time , $ timezone ) ; } else { $ dt = parent :: createFromFormat ( $ format , $ time ) ; } if ( $ dt instanceof \ DateTime ) { retu... | Create a DateTime instance from a specific format . |
233,360 | public static function Now ( \ DateTimeZone $ timezone = null , bool $ useDayStart = false , bool $ useDayEnd = false ) : DateTime { $ dt = new DateTime ( 'now' , $ timezone ) ; if ( $ useDayStart ) { $ dt -> setTime ( 0 , 0 , 0 ) ; } else if ( $ useDayEnd ) { $ dt -> setTime ( 23 , 59 , 59 ) ; } return $ dt ; } | Init s a \ Beluga \ Date \ DateTime with current DateTime and returns it . |
233,361 | public static function FromFile ( string $ file , bool $ checkIfFileExists = false ) { if ( $ checkIfFileExists && ! \ file_exists ( $ file ) ) { return false ; } try { return DateTime :: Parse ( \ filemtime ( $ file ) ) ; } catch ( \ Throwable $ ex ) { $ ex = null ; return false ; } } | Gets the last change DateTime of defined file . |
233,362 | public static function GetDaysInMonth ( int $ year , int $ month ) : int { $ dt = new \ DateTime ( ) ; $ dt -> setDate ( $ year , $ month , 2 ) ; $ dt -> setTime ( 0 , 0 , 2 ) ; return \ intval ( $ dt -> format ( 't' ) ) ; } | Gets the days of the defined month in defined year . |
233,363 | protected function initializeFiltering ( ContextInterface $ context ) { $ activeFilters = $ context -> getActiveFilters ( ) ; foreach ( $ activeFilters as $ activeFilter ) { $ filterName = $ activeFilter -> getFilterName ( ) ; if ( $ this -> table -> hasFilter ( $ filterName ) ) { $ this -> table -> getFilter ( $ filte... | Initializes filtering by applying all active filters through the related filter types . |
233,364 | protected function initializeSorting ( ContextInterface $ context ) { if ( null !== $ activeSort = $ context -> getActiveSort ( ) ) { $ columnName = $ activeSort -> getColumnName ( ) ; if ( $ this -> table -> hasColumn ( $ columnName ) ) { $ this -> table -> getColumn ( $ columnName ) -> applySort ( $ this , $ activeSo... | Initializes sorting by applying all active sorts through the related column types . |
233,365 | public static function generateWithCustomAlphabet ( $ customAlphabet = '0123456789ABCDEF' , $ tokenLength = 32 ) { $ generator = new RandomStringGenerator ( $ customAlphabet ) ; $ token = $ generator -> generate ( $ tokenLength ) ; return $ token ; } | Generate token with custom alphabet |
233,366 | public function init ( ) { $ this -> register ( 'request' , function ( $ app ) { return new Request ( $ app -> config [ 'baseurl' ] ) ; } ) ; $ this -> register ( 'response' , function ( $ app ) { return new Response ( ) ; } ) ; $ this -> register ( 'router' , function ( $ app ) { return new Router ( ) ; } ) ; $ app = ... | Initialise the IoC aliases and routes . |
233,367 | public function registerRoutes ( Map $ map ) { $ map -> attach ( 'legacy.' , '/' , function ( Map $ map ) { $ map -> get ( 'polls' , 'polls/' , $ this -> controller ( PollsController :: class , 'polls' ) ) -> allows ( [ 'POST' ] ) ; } ) ; } | Add the legacy route |
233,368 | public function load ( string $ resourceName , bool $ prependResourceName = false ) { switch ( $ this -> _handler -> load ( $ resourceName , $ prependResourceName ) ) { case Handler :: CONFIG_PARSE_ERROR : throw new Exception \ ConfigParseException ( "Error parsing '{$resourceName}' configuration resource" ) ; case Han... | Load config resource |
233,369 | public function setNavigationClass ( $ class ) { if ( is_string ( $ class ) && ! empty ( trim ( $ class ) ) ) { $ this -> menuElements [ 'ul_class' ] = $ class ; } if ( ( is_string ( $ class ) && empty ( trim ( $ class ) ) ) || $ class === false ) { $ this -> menuElements [ 'ul_class' ] = '' ; } return $ this ; } | Set the main navigation UL class |
233,370 | public function setNavigationID ( $ id ) { if ( is_string ( $ id ) && ! empty ( trim ( $ id ) ) ) { $ this -> menuElements [ 'ul_id' ] = $ id ; } if ( ( is_string ( $ id ) && empty ( trim ( $ id ) ) ) || $ id === false ) { $ this -> menuElements [ 'ul_id' ] = '' ; } return $ this ; } | Set the main navigation ID element |
233,371 | public function setDefaultClass ( $ class , $ element = 'li' ) { if ( in_array ( $ element , [ 'a' , 'li' , 'ul' ] ) && ( ( is_string ( $ class ) && ! empty ( trim ( $ class ) ) ) || is_bool ( $ class ) ) ) { $ this -> menuElements [ strtolower ( $ element ) . '_default' ] = $ class ; } elseif ( in_array ( $ element , ... | Change the default class assigned to all elements of a certain type in the menu |
233,372 | public function setCurrentURI ( $ uri ) { if ( is_string ( $ uri ) && ! empty ( trim ( $ uri ) ) ) { $ this -> currentURI = $ uri ; $ this -> currentArray = Levels :: getCurrent ( $ this -> navigation , $ this -> currentURI ) ; } else { throw new InvalidArgumentException ( '$uri must be a valid string when seting the c... | Sets the current active URI |
233,373 | public function hasLink ( $ link ) { $ found = false ; array_walk_recursive ( $ this -> navigation , function ( $ value , $ key ) use ( & $ found , $ link ) { if ( $ value == $ link && $ key === 'uri' ) { $ found = true ; } } ) ; return $ found ; } | Checks to see if a link exists within the current navigation array |
233,374 | public function hasLinks ( $ array ) { if ( is_array ( $ array ) ) { foreach ( $ array as $ link ) { if ( $ this -> hasLink ( $ link ) === false ) { return false ; } } return true ; } return false ; } | Checks to see if an array of links exist within the current navigation array |
233,375 | public function render ( ) { return Menu :: build ( $ this -> navigation , $ this -> menuElements , $ this -> currentArray , $ this -> getActiveClass ( ) , $ this -> getStartLevel ( ) , $ this -> getMaxLevels ( ) , $ this -> caretElement , $ this -> dropdownLinkExtras ) ; } | Returns the HTML navigation string |
233,376 | public function renderBreadcrumb ( $ class = 'breadcrumb' , $ itemClass = 'breadcrumb-item' , $ list = true ) { $ breadcrumb = new Breadcrumb ( ) ; $ breadcrumb -> navArray = $ this -> navigation ; return $ breadcrumb -> setBreacrumbLinks ( $ this -> currentArray ) -> createBreadcrumb ( $ class , $ itemClass , $ list )... | Renders a breadcrumb menu |
233,377 | public static function get ( array $ array , $ key = null , $ default = null ) { if ( $ key === null ) { return $ array ; } if ( isset ( $ array [ $ key ] ) ) { return static :: value ( $ array [ $ key ] ) ; } foreach ( explode ( '.' , ( string ) $ key ) as $ segment ) { if ( ! array_key_exists ( $ segment , $ array ) ... | Get an item from an array using dot notation . If key dont exist you get a default value back . |
233,378 | public static function add ( array $ array , $ key , $ value ) : array { $ target = static :: get ( $ array , $ key , [ ] ) ; if ( ! is_array ( $ target ) ) { $ target = [ $ target ] ; } $ target [ ] = $ value ; $ array = static :: set ( $ array , $ key , $ target ) ; return $ array ; } | Add an element to the array at a specific location using the dot notation . |
233,379 | public static function any ( array $ array , $ keys ) : bool { foreach ( ( array ) $ keys as $ key ) { if ( static :: has ( $ array , $ key ) ) { return true ; } } return false ; } | Check if any item or items exist in an array using dot notation . |
233,380 | public static function update ( array $ array , string $ key , callable $ callback ) { $ keys = explode ( '.' , $ key ) ; $ current = & $ array ; foreach ( $ keys as $ key ) { if ( ! isset ( $ current [ $ key ] ) ) { return $ array ; } $ current = & $ current [ $ key ] ; } $ current = $ callback ( $ current ) ; return ... | Updates data at the given path . |
233,381 | public static function closest ( array $ array , string $ value ) { sort ( $ array ) ; $ closest = $ array [ 0 ] ; for ( $ i = 1 , $ j = count ( $ array ) , $ k = 0 ; $ i < $ j ; $ i ++ , $ k ++ ) { $ middleValue = ( ( int ) $ array [ $ i ] - ( int ) $ array [ $ k ] ) / 2 + ( int ) $ array [ $ k ] ; if ( $ value >= $ m... | Return the closest found value from array . |
233,382 | public static function every ( array $ array , int $ step , int $ offset = 0 ) : array { $ new = [ ] ; $ position = 0 ; foreach ( $ array as $ key => $ item ) { if ( $ position % $ step === $ offset ) { $ new [ ] = $ item ; } ++ $ position ; } return $ new ; } | Create a new array consisting of every n - th element . |
233,383 | public static function combine ( array $ array , callable $ callback , bool $ overwrite = true ) : array { $ combined = [ ] ; foreach ( $ array as $ key => $ value ) { $ combinator = $ callback ( $ value , $ key ) ; if ( defined ( 'HHVM_VERSION' ) && version_compare ( HHVM_VERSION , '3.10.0' , '<=' ) ) { $ combinator -... | Indexes an array depending on the values it contains . |
233,384 | public static function collapse ( array $ array ) : array { $ newArray = [ ] ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( preg_match ( '/\./' , ( string ) $ key ) ) { $ key = substr ( $ key , 0 , - 2 ) ; } self :: recurseCollapse ( $ value , $ newArray , ( array ) $ key ) ; } else { $ ... | Collapse a nested array down to an array of flat key = > value pairs . |
233,385 | public static function reindex ( array $ array , array $ map , bool $ unmapped = true ) : array { $ reindexed = $ unmapped ? $ array : [ ] ; foreach ( $ map as $ from => $ to ) { if ( isset ( $ array [ $ from ] ) ) { $ reindexed [ $ to ] = $ array [ $ from ] ; } } return $ reindexed ; } | Reindexes a list of values . |
233,386 | public static function extend ( ) : array { $ merged = [ ] ; foreach ( func_get_args ( ) as $ array ) { foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) && static :: has ( $ merged , $ key ) && is_array ( $ merged [ $ key ] ) ) { $ merged [ $ key ] = static :: extend ( $ merged [ $ key ] , $ value ) ... | Extend one array with another . |
233,387 | public static function asHierarchy ( array $ array ) : array { $ hierarchy = [ ] ; foreach ( $ array as $ key => $ value ) { $ segments = explode ( '.' , ( string ) $ key ) ; $ valueSegment = array_pop ( $ segments ) ; $ branch = & $ hierarchy ; foreach ( $ segments as $ segment ) { if ( ! isset ( $ branch [ $ segment ... | Transforms a 1 - dimensional array into a multi - dimensional one exploding keys according to a separator . |
233,388 | public static function groupBy ( array $ array , callable $ callback = null ) : array { $ callback = $ callback ? : function ( $ value ) { return $ value ; } ; return array_reduce ( $ array , function ( $ buckets , $ value ) use ( $ callback ) { $ key = $ callback ( $ value ) ; if ( ! array_key_exists ( $ key , $ bucke... | Separates elements from an array into groups . The function maps an element to the key that will be used for grouping . If no function is passed the element itself will be used as key . |
233,389 | public static function flatten ( array $ array , string $ separator = null , string $ prepend = '' ) : array { $ flattened = [ ] ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ flattened = array_merge ( $ flattened , static :: flatten ( $ value , $ separator , $ prepend . $ key . $ separator... | Flatten a nested array to a separated key . |
233,390 | public static function expand ( array $ array , string $ prepend = '' ) : array { $ results = [ ] ; if ( $ prepend ) { $ prepend .= '.' ; } foreach ( $ array as $ key => $ value ) { if ( $ prepend ) { $ pos = strpos ( $ key , $ prepend ) ; if ( $ pos === 0 ) { $ key = substr ( $ key , strlen ( $ prepend ) ) ; } } $ res... | Expand a flattened array with dots to a multi - dimensional associative array . |
233,391 | public static function extendDistinct ( ) { $ merged = [ ] ; foreach ( func_get_args ( ) as $ array ) { foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) && static :: has ( $ merged , $ key ) && is_array ( $ merged [ $ key ] ) ) { if ( static :: isAssoc ( $ value ) && static :: isAssoc ( $ merged [ $ ... | Extend one array with another . Non associative arrays will not be merged but rather replaced . |
233,392 | public static function sort ( array $ array , callable $ callback , int $ options = SORT_REGULAR , bool $ descending = false ) : array { $ results = [ ] ; foreach ( $ array as $ key => $ value ) { $ results [ $ key ] = $ callback ( $ value , $ key ) ; } $ descending ? arsort ( $ results , $ options ) : asort ( $ result... | Sort the array using the given callback . |
233,393 | public static function map ( array $ array , callable $ callback ) { $ newArray = [ ] ; foreach ( $ array as $ key => $ item ) { $ result = $ callback ( $ item , $ key ) ; $ newArray = is_array ( $ result ) ? array_replace_recursive ( $ array , $ result ) : array_merge_recursive ( $ array , ( array ) $ result ) ; } ret... | Applies the callback to the elements of the given arrays |
233,394 | public static function all ( array $ array , callable $ predicate ) { foreach ( $ array as $ key => $ value ) { if ( ! $ predicate ( $ value , $ key , $ array ) ) { return false ; } } return true ; } | Returns whether every element of the array satisfies the given predicate or not . Works with Iterators too . |
233,395 | public static function writeJSON ( $ obj , $ buf = null ) { $ output = json_encode ( $ obj ) ; if ( $ output === false && json_last_error ( ) === JSON_ERROR_UTF8 ) { $ obj_fixed = Encoding :: fixUTF8 ( $ obj ) ; $ output = json_encode ( $ obj_fixed ) ; if ( $ output === false && json_last_error ( ) === JSON_ERROR_UTF8 ... | Encode the specified entity catching UTF8 errors . |
233,396 | public static function pprintJSON ( $ obj , $ indent = 0 , $ json_array = null , $ buf = null ) { if ( ! is_object ( $ obj ) && ! is_array ( $ obj ) ) return self :: writeJSON ( $ obj , $ buf ) ; if ( method_exists ( $ obj , "jsonSerialize" ) ) { $ obj = $ obj -> jsonSerialize ( ) ; } elseif ( ! WF :: is_array_like ( $... | PrettyPrint the specified output . |
233,397 | private function createFileLocator ( $ modelDir , $ mixinDir , $ embedDir ) { $ definition = new Definition ( Utility :: getLibraryClass ( 'Metadata\Driver\FileLocator' ) , [ $ modelDir , $ mixinDir , $ embedDir ] ) ; $ definition -> setPublic ( false ) ; return $ definition ; } | Creates the file locator service definition . |
233,398 | private function createYmlDriver ( $ driverName , array $ driverConfig , ContainerBuilder $ container ) { list ( $ modelDir , $ mixinDir , $ embedDir ) = $ this -> getDefinitionDirs ( $ driverConfig , $ container ) ; Utility :: appendParameter ( 'dirs' , sprintf ( '%s.model_dir' , $ driverName ) , $ modelDir , $ contai... | Creates the YAML metadata driver service definition . |
233,399 | private function getDefinitionDir ( $ type , array $ driverConfig , ContainerBuilder $ container ) { $ defaultDir = sprintf ( '%s/Resources/As3ModlrBundle' , $ container -> getParameter ( 'kernel.root_dir' ) ) ; $ folder = sprintf ( '%ss' , $ type ) ; $ key = sprintf ( '%s_dir' , $ type ) ; return isset ( $ driverConfi... | Gets the directory for a definition type . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.