idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
11,700
public function syncDictionary ( ) { $ this -> kernel = $ this -> get ( 'kernel' ) ; $ this -> locales = $ this -> getLocales ( ) ; $ this -> propertyAccessor = PropertyAccess :: createPropertyAccessor ( ) ; $ this -> filesystem = new Filesystem ( ) ; foreach ( $ this -> locales as $ locale ) { $ this -> updateFilesyst...
Synchronizes database and filesystem translations
11,701
protected function get_field ( \ WP_Post $ post ) { $ html = parent :: get_field ( $ post ) ; return $ html . sprintf ( '<p class="inline-error"><i class="dashicons dashicons-location-alt"></i> %s</p>' , $ this -> __ ( 'Can\'t find map point. Try another string' ) ) ; }
Add error message .
11,702
public static function setHTML ( $ id , $ html ) { $ js = '$("' . $ id . '").html(' . json_encode ( $ html ) . ');' ; return self :: execHeader ( $ js ) ; }
Uses jsexec_header to set the innerHTML of an element by id
11,703
public static function execScript ( $ script_path , $ context = null ) { header ( 'Content-type: text/javascript' ) ; if ( ! is_null ( $ context ) ) { if ( is_object ( $ context ) ) { $ context = get_object_vars ( $ context ) ; } if ( is_array ( $ context ) ) { extract ( $ context ) ; } } require ( $ script_path ) ; }
Executes a script at a certain path
11,704
private function processMetadataDrivers ( ) { $ builder = $ this -> getContainerBuilder ( ) ; $ annotationReader = $ builder -> addDefinition ( $ this -> prefix ( 'metadata.annotationReader' ) ) -> setClass ( AnnotationReader :: class ) ; $ cachedReader = $ builder -> addDefinition ( $ this -> prefix ( 'metadata.cached...
Registers metadata drivers .
11,705
private function createServiceName ( string $ namespace ) { $ parts = explode ( '\\' , $ namespace ) ; foreach ( $ parts as $ k => $ part ) { $ parts [ $ k ] = lcfirst ( $ part ) ; } return trim ( implode ( '.' , $ parts ) , '.' ) ; }
Converts PHP namespace to service name .
11,706
private function processConnection ( ) { $ builder = $ this -> getContainerBuilder ( ) ; $ connection = $ builder -> addDefinition ( $ this -> prefix ( 'connection' ) ) -> setClass ( Connection :: class ) -> setFactory ( DriverManager :: class . '::getConnection' , [ $ this -> config [ 'connection' ] ] ) ; }
Registers DBAL connection .
11,707
private function processEvents ( ) { $ builder = $ this -> getContainerBuilder ( ) ; $ eventManager = $ builder -> addDefinition ( $ this -> prefix ( 'eventManager' ) ) -> setClass ( EventManager :: class ) ; $ entityListenerResolver = $ builder -> addDefinition ( $ this -> prefix ( 'entityListenerResolver' ) ) -> setC...
Registers Event Manager .
11,708
private function processEntityManager ( ) { $ builder = $ this -> getContainerBuilder ( ) ; $ configuration = $ builder -> addDefinition ( $ this -> prefix ( 'configuration' ) ) -> setClass ( Configuration :: class ) -> addSetup ( '$service->setMetadataDriverImpl($this->getService(?))' , [ $ this -> prefix ( 'metadata....
Registers Entity Manager .
11,709
private function processCachingServices ( ) { $ this -> createCache ( 'annotations' ) ; $ this -> createCache ( 'metadata' ) ; $ this -> createCache ( 'query' ) ; $ this -> createCache ( 'result' ) ; $ this -> createCache ( 'hydration' ) ; }
Registers caching services .
11,710
private function createCache ( string $ name ) { $ builder = $ this -> getContainerBuilder ( ) ; $ cache = $ builder -> addDefinition ( $ this -> prefix ( 'cache.' . $ name ) ) -> setClass ( Cache :: class ) -> setArguments ( [ '@Nette\Caching\IStorage' , $ this -> debugMode ] ) -> addSetup ( '$service->setNamespace(?)...
Creates a caching service .
11,711
private function processConsole ( ) { $ builder = $ this -> getContainerBuilder ( ) ; $ console = $ builder -> addDefinition ( $ this -> prefix ( 'console' ) ) -> setClass ( Application :: class ) -> setArguments ( [ 'Doctrine Command Line Interface' , \ Doctrine \ ORM \ Version :: VERSION ] ) -> addSetup ( '?->setCatc...
Registers Doctrine Console .
11,712
private function processTracy ( ) { $ builder = $ this -> getContainerBuilder ( ) ; $ tracyPanel = $ builder -> addDefinition ( $ this -> prefix ( 'tracyPanel' ) ) -> setClass ( Panel :: class ) ; $ builder -> getDefinition ( $ this -> prefix ( 'entityManager' ) ) -> addSetup ( '?->setEntityManager(?)' , [ '@' . $ this...
Registers debug panel .
11,713
public function preview ( $ id ) { $ item = app ( StackRepository :: class ) -> fetchOne ( ( int ) $ id ) -> firstOrFail ( ) ; if ( in_array ( $ item -> notification -> type -> name , [ 'email' , 'sms' ] ) ) { $ classname = $ item -> notification -> type -> name === 'email' ? EmailNotification :: class : SmsNotificatio...
Preview notification log
11,714
public function delete ( LogsListener $ listener , $ id = null ) : RedirectResponse { $ stack = ! empty ( $ ids = input ( 'attr' ) ) ? $ this -> stack -> newQuery ( ) -> whereIn ( 'id' , $ ids ) : $ this -> stack -> newQuery ( ) -> findOrFail ( $ id ) ; if ( $ stack -> delete ( ) ) { return $ listener -> deleteSuccess ...
Deletes notification log
11,715
protected function checkDumpDir ( ) { if ( ! is_dir ( $ this -> dump_dir ) ) { mkdir ( $ this -> dump_dir , 0700 , true ) ; } foreach ( \ range ( $ this -> max_version , 1 ) as $ version ) { $ dir = $ this -> dump_dir . $ version ; if ( is_dir ( $ dir ) ) { if ( $ version == $ this -> max_version ) { $ this -> recursiv...
check to make sure dump directory exists and if not create it
11,716
protected function dumpDatabases ( ) { foreach ( $ this -> db -> query ( "SHOW DATABASES" ) as $ list ) { $ database = $ list -> Database ; if ( ! in_array ( $ database , $ this -> ignore ) || preg_match ( "~_no_backup$~" , $ database ) ) { $ start = microtime ( true ) ; $ dir = $ this -> dump_dir . '1/' ; $ filename =...
Dump the database files and gzip add version number
11,717
protected function log ( $ message ) { if ( $ this -> debug == true ) { file_put_contents ( "php://stdout" , $ message . "\n" ) ; } file_put_contents ( $ this -> dump_dir . 'dump.log' , $ message . "\n" , \ FILE_APPEND ) ; }
Send messages to stdout
11,718
protected function recursiveDelete ( $ dir , $ del = 0 ) { if ( substr ( $ dir , 0 , 1 ) == '/' ) { throw new \ Exception ( "You cannot delete root directories" ) ; } $ iterator = new \ RecursiveDirectoryIterator ( $ dir ) ; foreach ( new \ RecursiveIteratorIterator ( $ iterator , \ RecursiveIteratorIterator :: CHILD_F...
Recursively deletes the files in a diretory
11,719
public function addNotifier ( Notifier $ notifier , bool $ setLogger = true ) { if ( $ notifier instanceof self ) { throw new LogicException ( 'Cannot add self' ) ; } if ( $ setLogger ) { $ notifier -> setLogger ( $ this -> getLogger ( ) ) ; } $ this -> notifiers [ ] = $ notifier ; }
Add a notifier to the Notification center .
11,720
function devoid ( $ key ) { $ val = $ this -> ref ( $ key , FALSE ) ; return empty ( $ val ) && ( ! Cache :: instance ( ) -> exists ( $ this -> hash ( $ key ) . '.var' , $ val ) || ! $ val ) ; }
Return TRUE if hive key is empty and not cached
11,721
function get ( $ key , $ args = NULL ) { if ( is_string ( $ val = $ this -> ref ( $ key , FALSE ) ) && ! is_null ( $ args ) ) return call_user_func_array ( array ( $ this , 'format' ) , array_merge ( array ( $ val ) , is_array ( $ args ) ? $ args : array ( $ args ) ) ) ; if ( is_null ( $ val ) ) { if ( Cache :: instanc...
Retrieve contents of hive key
11,722
function pre ( $ data , $ exit = false ) { echo '<pre>' ; print_r ( $ data ) ; echo '</pre>' ; ! $ exit || exit ( str_repeat ( '<br>' , 2 ) . ' ' . $ exit ) ; echo '<hr>' ; }
Output the data
11,723
function constants ( $ class , $ prefix = '' ) { $ ref = new ReflectionClass ( $ class ) ; $ out = array ( ) ; foreach ( preg_grep ( '/^' . $ prefix . '/' , array_keys ( $ ref -> getconstants ( ) ) ) as $ val ) { $ out [ $ key = substr ( $ val , strlen ( $ prefix ) ) ] = constant ( ( is_object ( $ class ) ? get_class (...
Convert class constants to array
11,724
function recursive ( $ arg , $ func , $ stack = NULL ) { if ( $ stack ) { foreach ( $ stack as $ node ) if ( $ arg === $ node ) return $ arg ; } else $ stack = array ( ) ; switch ( gettype ( $ arg ) ) { case 'object' : if ( method_exists ( 'ReflectionClass' , 'iscloneable' ) ) { $ ref = new ReflectionClass ( $ arg ) ; ...
Invoke callback recursively for all data types
11,725
function map ( $ url , $ class , $ ttl = 0 , $ kbps = 0 ) { if ( is_array ( $ url ) ) { foreach ( $ url as $ item ) $ this -> map ( $ item , $ class , $ ttl , $ kbps ) ; return ; } foreach ( explode ( '|' , self :: VERBS ) as $ method ) $ this -> route ( $ method . ' ' . $ url , is_string ( $ class ) ? $ class . '->' ....
Provide ReST interface by mapping HTTP verb to class method
11,726
function highlight ( $ text ) { $ out = '' ; $ pre = FALSE ; $ text = trim ( $ text ) ; if ( ! preg_match ( '/^<\?php/' , $ text ) ) { $ text = '<?php ' . $ text ; $ pre = TRUE ; } foreach ( token_get_all ( $ text ) as $ token ) if ( $ pre ) $ pre = FALSE ; else $ out .= '<span' . ( is_array ( $ token ) ? ( ' class="' ...
Apply syntax highlighting
11,727
public function getApiRequestUrl ( Event $ event ) { $ params = $ event -> getCustomParams ( ) ; $ query = trim ( implode ( " " , $ params ) ) ; $ querystringParams = [ 'v' => '1.0' , 'q' => $ query ] ; return sprintf ( "%s?%s" , $ this -> apiUrl , http_build_query ( $ querystringParams ) ) ; }
Get the url for the API request
11,728
public function getHtmlHelper ( ) { $ this -> HtmlHelper -> Form -> getDataService ( ) -> template = $ this -> template ; $ this -> HtmlHelper -> getRouterService ( ) -> template = $ this -> template ; $ this -> HtmlHelper -> getAssetsService ( ) -> template = $ this -> template ; return $ this -> HtmlHelper ; }
return the instance of the html helper
11,729
public function display ( ) { $ path = func_get_args ( ) ; $ count = count ( $ path ) ; if ( ! $ count ) { return $ this -> redirect ( '/' ) ; } $ page = $ subpage = $ title_for_layout = null ; if ( ! empty ( $ path [ 0 ] ) ) { $ page = $ path [ 0 ] ; } if ( ! empty ( $ path [ 1 ] ) ) { $ subpage = $ path [ 1 ] ; } if ...
Displays a view
11,730
public function run ( ) { $ this -> loader -> parse ( ) ; $ files = $ this -> filesystem -> getFiles ( ) ; while ( $ files -> valid ( ) ) { $ file = $ files -> current ( ) ; if ( $ file -> isLink ( ) ) { $ files -> next ( ) ; continue ; } $ filename = $ this -> getRelativeFilename ( $ file ) ; if ( $ this -> isExcluded...
Run the permission check and return any errors
11,731
protected function isExcluded ( $ filename ) { foreach ( $ this -> config -> getExcludedFiles ( ) as $ excludedFile ) { if ( $ filename === $ excludedFile ) { return true ; } } foreach ( $ this -> config -> getExcludedDirs ( ) as $ excludedDir ) { if ( strpos ( $ filename , $ excludedDir ) === 0 ) { return true ; } } r...
Check whether the given file should be excluded .
11,732
protected function shouldBeExecutable ( $ filename ) { foreach ( $ this -> config -> getExecutableFiles ( ) as $ exFile ) { if ( $ filename === $ exFile ) { return true ; } } return false ; }
Check whether the given file should be executable .
11,733
protected function getRelativeFilename ( SplFileInfo $ file ) { $ filename = $ file -> getPathname ( ) ; $ regex = sprintf ( '#^(%s)/(.+)#' , $ this -> directory ) ; $ matches = array ( ) ; preg_match ( $ regex , $ filename , $ matches ) ; return $ matches [ 2 ] ; }
Get the relative name of the given file .
11,734
public function walk ( ) { if ( $ this -> dom instanceof \ DOMDocument ) { $ this -> rules -> document ( $ this -> dom ) ; } elseif ( $ this -> dom instanceof \ DOMDocumentFragment ) { if ( $ this -> dom -> hasChildNodes ( ) ) { $ this -> children ( $ this -> dom -> childNodes ) ; } } elseif ( $ this -> dom instanceof ...
Tell the traverser to walk the DOM .
11,735
public function node ( \ DOMNode $ node ) { switch ( $ node -> nodeType ) { case XML_ELEMENT_NODE : $ this -> rules -> element ( $ node ) ; break ; case XML_TEXT_NODE : $ this -> rules -> text ( $ node ) ; break ; case XML_CDATA_SECTION_NODE : $ this -> rules -> cdata ( $ node ) ; break ; case XML_PI_NODE : $ this -> r...
Process a node in the DOM .
11,736
public function isLocalElement ( $ element ) { $ uri = $ element -> namespaceURI ; if ( empty ( $ uri ) ) { return false ; } return isset ( static :: $ local_ns [ $ uri ] ) ; }
Is an element local?
11,737
private function setupRules ( $ rules ) { $ rules = Utils \ HelperRequiredIf :: prepare ( $ this , $ rules ) ; $ rules = Utils \ HelperSameWith :: prepare ( $ this , $ rules ) ; return $ rules ; }
set up rules ; - add required rule based on requiredIf rule . - add sameAs rule based on sameWith rule .
11,738
private function existsParamTagWithArgument ( $ parameters , ArgumentDescriptor $ argument ) { foreach ( $ parameters as $ parameter ) { if ( $ argument -> getName ( ) == $ parameter -> getVariableName ( ) ) { return true ; } } return false ; }
Returns whether the list of param tags features the given argument .
11,739
protected function getProgressBar ( InputInterface $ input ) { $ progress = parent :: getProgressBar ( $ input ) ; if ( ! $ progress ) { return null ; } $ this -> getService ( 'event_dispatcher' ) -> addListener ( 'parser.file.pre' , function ( PreFileEvent $ event ) use ( $ progress ) { $ progress -> advance ( ) ; } )...
Adds the parser . file . pre event to the advance the progressbar .
11,740
protected function compileUpdateJoinWheres ( Builder $ query ) { $ joinWheres = [ ] ; foreach ( $ query -> joins as $ join ) { foreach ( $ join -> wheres as $ where ) { $ method = "where{$where['type']}" ; $ joinWheres [ ] = $ where [ 'boolean' ] . ' ' . $ this -> { $ method } ( $ query , $ where ) ; } } return implode...
Compile the join clause where clauses for an update .
11,741
public function onRequestSent ( Event $ event ) { $ request = $ event [ 'request' ] ; $ response = $ event [ 'response' ] ; $ exception = $ event [ 'exception' ] ; $ params = $ request -> getParams ( ) ; $ retries = ( int ) $ params -> get ( self :: RETRY_PARAM ) ; $ delay = $ this -> strategy -> getBackoffPeriod ( $ r...
Called when a request has been sent and isn t finished processing
11,742
private function createPackages ( array $ packages ) { $ matcherPackages = [ ] ; foreach ( $ packages as $ package ) { $ reflection = new ReflectionClass ( $ package ) ; if ( $ reflection -> implementsInterface ( self :: PACKAGE_REGISTRAR ) === false ) { throw NotAvailableException :: createForPackage ( self :: PACKAGE...
Create a few new package registrars
11,743
private function createReporter ( $ reporter ) { $ reflection = new ReflectionClass ( $ reporter ) ; if ( $ reflection -> implementsInterface ( self :: REPORTER ) === false ) { throw NotAvailableException :: createForReporter ( self :: REPORTER ) ; } return $ reflection -> newInstance ( ) ; }
Create a new result reporter
11,744
protected function getObject ( $ path ) { $ location = $ this -> applyPathPrefix ( $ path ) ; return $ this -> container -> getObject ( $ location ) ; }
Get an object .
11,745
protected function getRootPath ( PackageInterface $ package ) { $ rootPath = $ this -> vendorDir . '/raulfraile/ladybug-themes/Ladybug/' ; if ( $ this -> composer -> getPackage ( ) -> getName ( ) === 'raulfraile/ladybug' ) { $ rootPath = 'data/' . ( $ package -> getType ( ) === self :: PACKAGE_TYPE_THEME ? 'themes' : '...
Returns the root installation path for templates .
11,746
public function consume ( AbstractConsumer $ consumer , $ auto_ack = false ) { if ( ! $ consumer -> active ( ) ) { return ; } $ outside_error = null ; try { $ consumer -> begin ( $ this ) ; $ this -> queue -> consume ( function ( AMQPEnvelope $ envelope ) use ( $ consumer ) { $ delivery = $ this -> builder -> build ( $...
Attach consumer to process payload from queue
11,747
protected function get_options ( ) { $ terms = get_terms ( $ this -> name ) ; if ( ! $ terms || is_wp_error ( $ terms ) ) { return [ ] ; } else { $ result = [ ] ; foreach ( $ terms as $ term ) { $ result [ $ term -> term_id ] = $ term -> name ; } return $ result ; } }
Get terms as option
11,748
protected function buttons ( $ fluent , Fieldset $ fieldset ) { $ fieldset -> control ( 'button' , 'cancel' ) -> field ( function ( ) { return app ( 'html' ) -> link ( handles ( "antares::notifications/" ) , trans ( 'Cancel' ) , [ 'class' => 'btn btn--md btn--default mdl-button mdl-js-button' ] ) ; } ) ; $ acl = app ( ...
buttons in form
11,749
public function onCreate ( ) { $ this -> grid -> attributes ( [ 'url' => handles ( 'antares::notifications/store' ) , 'method' => 'POST' , ] ) ; $ layout = ( $ this -> fluent -> type == 'sms' ) ? 'antares/notifications::admin.index.form_sms' : 'antares/notifications::admin.index.form' ; $ this -> grid -> layout ( $ lay...
on create scenario
11,750
protected function getNotificationContentData ( $ fluent , $ langId , $ key = 'title' ) { foreach ( $ fluent -> contents as $ content ) { if ( $ langId !== $ content [ 'lang_id' ] ) { continue ; } return array_get ( $ content , $ key ) ; } return '' ; }
Gets notification data
11,751
public function delete ( ) { if ( $ this -> isNewRecord ( ) ) { throw new DeleteModelException ( "New models can't be deleted." ) ; } $ this -> beforeDelete ( ) ; $ this -> raiseEvent ( "BeforeDelete" ) ; $ this -> Deleted = true ; $ this -> save ( ) ; $ this -> afterDelete ( ) ; $ this -> raiseEvent ( "AfterDelete" ) ...
Replaces the standard delete by flagging the entry deleted instead .
11,752
protected function _init ( $ definition = null ) { if ( ! is_null ( $ definition ) ) { $ this -> _packageXml = simplexml_load_string ( $ definition ) ; } else { $ packageXmlStub = <<<END<?xml version="1.0"?><package> <name /> <version /> <stability /> <license /> <channel /> <extends /> <summary /...
Initializes an empty package object
11,753
protected function _loadFile ( $ filename = '' ) { if ( is_null ( $ this -> _reader ) ) { $ this -> _reader = new Mage_Connect_Package_Reader ( $ filename ) ; } $ content = $ this -> _reader -> load ( ) ; $ this -> _packageXml = simplexml_load_string ( $ content ) ; return $ this ; }
Loads a package from specified file
11,754
public function save ( $ path ) { $ this -> validate ( ) ; $ path = rtrim ( $ path , "\\/" ) . DS ; $ this -> _savePackage ( $ path ) ; return $ this ; }
Creates a package and saves it
11,755
protected function _savePackage ( $ path ) { $ fileName = $ this -> getReleaseFilename ( ) ; if ( is_null ( $ this -> _writer ) ) { $ this -> _writer = new Mage_Connect_Package_Writer ( $ this -> getContents ( ) , $ path . $ fileName ) ; } $ this -> _writer -> composePackage ( ) -> addPackageXml ( $ this -> getPackageX...
Creates a package archive and saves it to specified path
11,756
protected function _getNode ( $ tag , $ parent , $ name = '' ) { $ found = false ; foreach ( $ parent -> xpath ( $ tag ) as $ _node ) { if ( $ _node [ 'name' ] == $ name ) { $ node = $ _node ; $ found = true ; break ; } } if ( ! $ found ) { $ node = $ parent -> addChild ( $ tag ) ; if ( $ name ) { $ node -> addAttribut...
Retrieve SimpleXMLElement node by xpath . If it absent create new . For comparing nodes method uses attribute name in each nodes . If attribute name is same for both nodes nodes are same .
11,757
public function setDependencyPhpVersion ( $ minVersion , $ maxVersion ) { $ parent = $ this -> _packageXml -> dependencies ; $ parent = $ this -> _getNode ( 'required' , $ parent ) ; $ parent = $ this -> _getNode ( 'php' , $ parent ) ; $ parent -> addChild ( 'min' , $ minVersion ) ; $ parent -> addChild ( 'max' , $ max...
Set dependency from php version .
11,758
public function checkPhpVersion ( ) { $ min = $ this -> getDependencyPhpVersionMin ( ) ; $ max = $ this -> getDependencyPhpVersionMax ( ) ; $ minOk = $ min ? version_compare ( PHP_VERSION , $ min , ">=" ) : true ; $ maxOk = $ max ? version_compare ( PHP_VERSION , $ max , "<=" ) : true ; if ( ! $ minOk || ! $ maxOk ) { ...
Check PHP version restriction
11,759
public function checkPhpDependencies ( ) { $ errors = array ( ) ; foreach ( $ this -> getDependencyPhpExtensions ( ) as $ dep ) { if ( ! extension_loaded ( $ dep [ 'name' ] ) ) { $ errors [ ] = $ dep ; } } if ( count ( $ errors ) ) { return $ errors ; } return true ; }
Check PHP extensions availability
11,760
public function setDependencyPhpExtensions ( $ extensions ) { foreach ( $ extensions as $ _extension ) { $ this -> addDependencyExtension ( $ _extension [ 'name' ] , $ _extension [ 'min_version' ] , $ _extension [ 'max_version' ] ) ; } return $ this ; }
Set dependency from php extensions .
11,761
public function setDependencyPackages ( $ packages , $ clear = false ) { if ( $ clear ) { unset ( $ this -> _packageXml -> dependencies -> required -> package ) ; } foreach ( $ packages as $ _package ) { $ filesArrayCondition = isset ( $ _package [ 'files' ] ) && is_array ( $ _package [ 'files' ] ) ; $ filesArray = $ f...
Set dependency from another packages .
11,762
public function addDependencyPackage ( $ name , $ channel , $ minVersion , $ maxVersion , $ files = array ( ) ) { $ parent = $ this -> _packageXml -> dependencies ; $ parent = $ this -> _getNode ( 'required' , $ parent ) ; $ parent = $ parent -> addChild ( 'package' ) ; $ parent -> addChild ( 'name' , $ name ) ; $ pare...
Add package to dependency packages .
11,763
public function addDependencyExtension ( $ name , $ minVersion , $ maxVersion ) { $ parent = $ this -> _packageXml -> dependencies ; $ parent = $ this -> _getNode ( 'required' , $ parent ) ; $ parent = $ parent -> addChild ( 'extension' ) ; $ parent -> addChild ( 'name' , $ name ) ; $ parent -> addChild ( 'min' , $ min...
Add package to dependency extension .
11,764
public function getAuthors ( ) { if ( is_array ( $ this -> _authors ) ) return $ this -> _authors ; $ this -> _authors = array ( ) ; if ( ! isset ( $ this -> _packageXml -> authors -> author ) ) { return array ( ) ; } foreach ( $ this -> _packageXml -> authors -> author as $ _author ) { $ this -> _authors [ ] = array (...
Get list of authors in associative array .
11,765
public function getContents ( ) { if ( is_array ( $ this -> _contents ) ) return $ this -> _contents ; $ this -> _contents = array ( ) ; if ( ! isset ( $ this -> _packageXml -> contents -> target ) ) { return $ this -> _contents ; } foreach ( $ this -> _packageXml -> contents -> target as $ target ) { $ targetUri = $ t...
Create list of all files from package . xml
11,766
public function getHashContents ( ) { if ( is_array ( $ this -> _hashContents ) ) return $ this -> _hashContents ; $ this -> _hashContents = array ( ) ; if ( ! isset ( $ this -> _packageXml -> contents -> target ) ) { return $ this -> _hashContents ; } foreach ( $ this -> _packageXml -> contents -> target as $ target )...
Create list of all files from package . xml with hash
11,767
public function getCompatible ( ) { if ( is_array ( $ this -> _compatible ) ) return $ this -> _compatible ; $ this -> _compatible = array ( ) ; if ( ! isset ( $ this -> _packageXml -> compatible -> package ) ) { return array ( ) ; } foreach ( $ this -> _packageXml -> compatible -> package as $ _package ) { $ this -> _...
Get compatible packages .
11,768
public function getDependencyPhpExtensions ( ) { if ( is_array ( $ this -> _dependencyPhpExtensions ) ) return $ this -> _dependencyPhpExtensions ; $ this -> _dependencyPhpExtensions = array ( ) ; if ( ! isset ( $ this -> _packageXml -> dependencies -> required -> extension ) ) { return $ this -> _dependencyPhpExtensio...
Get list of php extensions .
11,769
public function getDependencyPackages ( ) { $ this -> _dependencyPackages = array ( ) ; if ( ! isset ( $ this -> _packageXml -> dependencies -> required -> package ) ) { return $ this -> _dependencyPackages ; } foreach ( $ this -> _packageXml -> dependencies -> required -> package as $ _package ) { $ add = array ( 'nam...
Get list of dependency packages .
11,770
public function convertChannelFromV1x ( $ channel ) { $ channelMap = array ( 'connect.magentocommerce.com/community' => 'community' , 'connect.magentocommerce.com/core' => 'community' ) ; if ( ! empty ( $ channel ) && isset ( $ channelMap [ $ channel ] ) ) { $ channel = $ channelMap [ $ channel ] ; } return $ channel ;...
Convert package channel in order for it to be compatible with current version of Magento Connect Manager
11,771
private function getUniqueKey ( ) : string { do { try { $ isDuplicate = null ; $ key = random_bytes ( $ this -> getOpt ( self :: OPT_SESSION_KEY_LENGTH ) ) ; $ this -> emit ( 'duplicate-check' , [ $ key , & $ isDuplicate ] ) ; } catch ( \ Exception $ e ) { throw new SessionException ( $ e -> getMessage ( ) , SessionExc...
Generate unique key
11,772
public static function parseHeaders ( string $ rawHeaders ) : array { if ( empty ( trim ( $ rawHeaders ) ) ) { throw new InvalidArgumentException ( '$rawHeaders cannot be whitespace' ) ; } $ headers = [ ] ; $ rawHeaders = preg_replace ( "/\r\n[\t ]+/" , ' ' , trim ( $ rawHeaders ) ) ; $ fields = explode ( "\r\n" , $ ra...
Parses HTTP headers into an associative array .
11,773
public static function buildQueryString ( array $ parameters ) : string { $ queryStrings = [ ] ; foreach ( $ parameters as $ parameterName => $ parameterValue ) { $ parameterName = rawurlencode ( $ parameterName ) ; if ( is_array ( $ parameterValue ) ) { foreach ( $ parameterValue as $ eachValue ) { $ eachValue = rawur...
Generate URL - encoded query string
11,774
protected function routes ( ) { if ( $ this -> app -> routesAreCached ( ) ) { return ; } Route :: middleware ( [ 'nova' , Authorize :: class ] ) -> prefix ( 'nova-vendor/nova-spotify-auth-tool' ) -> group ( __DIR__ . '/../routes/web.php' ) ; Route :: middleware ( [ 'nova' , Authorize :: class ] ) -> prefix ( 'nova-vend...
Register the tool s routes .
11,775
public function add_meta_boxes ( $ post_type , $ post ) { if ( $ this -> is_valid_post_type ( $ post_type ) && $ this -> has_cap ( ) ) { if ( empty ( $ this -> name ) || empty ( $ this -> label ) ) { $ message = sprintf ( $ this -> __ ( '<code>%s</code> has invalid name or label.' ) , get_called_class ( ) ) ; add_actio...
Register meta box
11,776
public static function autoload ( $ className ) { Eresus_Kernel :: log ( __METHOD__ , LOG_DEBUG , '(%s)' , $ className ) ; ezcBase :: setPackageDir ( ) ; if ( array_key_exists ( $ className , ezcBase :: $ autoloadArray ) ) { if ( ezcBase :: $ autoloadArray [ $ className ] == false ) { return false ; } ezcBase :: loadFi...
Tries to autoload the given className . If the className could be found this method returns true otherwise false .
11,777
protected static function setPackageDir ( ) { if ( ezcBase :: $ packageDir !== null ) { return ; } $ baseDir = dirname ( __FILE__ ) ; switch ( ezcBase :: $ libraryMode ) { case "custom" : ezcBase :: $ packageDir = self :: $ currentWorkingDirectory . '/' ; break ; case "devel" : case "tarball" : ezcBase :: $ packageDir ...
Figures out the base path of the eZ Components installation .
11,778
protected static function requireFile ( $ fileName , $ className , $ prefix ) { $ autoloadDir = ezcBase :: $ packageDir . "autoload/" ; if ( $ prefix === 'ezc' && file_exists ( "$autoloadDir$fileName" ) ) { $ array = require ( "$autoloadDir$fileName" ) ; if ( is_array ( $ array ) && array_key_exists ( $ className , $ a...
Tries to load the autoload array and if loaded correctly includes the class .
11,779
public static function checkDependency ( $ component , $ type , $ value ) { switch ( $ type ) { case self :: DEP_PHP_EXTENSION : if ( extension_loaded ( $ value ) ) { return ; } else { die ( "\nThe {$component} component depends on the default PHP extension '{$value}', which is not loaded.\n" ) ; } break ; case self ::...
Checks for dependencies on PHP versions or extensions
11,780
public static function getRepositoryDirectories ( ) { $ autoloadDirs = array ( ) ; ezcBase :: setPackageDir ( ) ; $ repositoryDir = self :: $ currentWorkingDirectory ? self :: $ currentWorkingDirectory : ( realpath ( dirname ( __FILE__ ) . '/../../' ) ) ; $ autoloadDirs [ 'ezc' ] = new ezcBaseRepositoryDirectory ( ezcB...
Return the list of directories that contain class repositories .
11,781
public static function addClassRepository ( $ basePath , $ autoloadDirPath = null , $ prefix = null ) { if ( ! is_dir ( $ basePath ) ) { throw new ezcBaseFileNotFoundException ( $ basePath , 'base directory' ) ; } if ( is_null ( $ autoloadDirPath ) ) { $ autoloadDirPath = $ basePath . '/autoload' ; } if ( ! is_dir ( $ ...
Adds an additional class repository .
11,782
public static function getInstallationPath ( ) { self :: setPackageDir ( ) ; $ path = realpath ( self :: $ packageDir ) ; if ( substr ( $ path , - 1 ) !== DIRECTORY_SEPARATOR ) { $ path .= DIRECTORY_SEPARATOR ; } return $ path ; }
Returns the base path of the eZ Components installation
11,783
public static function setRunMode ( $ runMode ) { if ( ! in_array ( $ runMode , array ( ezcBase :: MODE_PRODUCTION , ezcBase :: MODE_DEVELOPMENT ) ) ) { throw new ezcBaseValueException ( 'runMode' , $ runMode , 'ezcBase::MODE_PRODUCTION or ezcBase::MODE_DEVELOPMENT' ) ; } self :: $ runMode = $ runMode ; }
Sets the development mode to the one specified .
11,784
public static function parse ( $ value , $ exceptionOnInvalidType = false , $ objectSupport = false ) { self :: $ exceptionOnInvalidType = $ exceptionOnInvalidType ; self :: $ objectSupport = $ objectSupport ; $ value = trim ( $ value ) ; if ( 0 == strlen ( $ value ) ) { return '' ; } if ( function_exists ( 'mb_interna...
Converts a YAML string to a PHP array .
11,785
public static function parseScalar ( $ scalar , $ delimiters = null , $ stringDelimiters = array ( '"' , "'" ) , & $ i = 0 , $ evaluate = true ) { if ( in_array ( $ scalar [ $ i ] , $ stringDelimiters ) ) { $ output = self :: parseQuotedScalar ( $ scalar , $ i ) ; if ( null !== $ delimiters ) { $ tmp = ltrim ( substr (...
Parses a scalar to a YAML string .
11,786
public function forgotCheckAction ( Request $ request ) { $ error = null ; $ last_email = null ; $ userService = $ this -> get ( "flowcode.user" ) ; $ user = $ userService -> loadUserByUsername ( $ request -> get ( "_username" ) ) ; if ( $ user ) { $ userService -> resetPasssword ( $ user ) ; } else { $ error = array (...
Forget check .
11,787
public function view ( $ user , Event $ event ) { if ( $ event -> creator -> id == $ user -> id ) { return true ; } return User :: findOrFail ( $ user -> id ) -> hasPermission ( 'laralum::events.view' ) ; }
Determine if the current user can view events .
11,788
public function publicDelete ( $ user , Event $ event ) { if ( $ event -> creator -> id == $ user -> id ) { return User :: findOrFail ( $ user -> id ) -> hasPermission ( 'laralum::events.delete-public' ) ; } return false ; }
Determine if the current user can delete events on public views .
11,789
public function routeError ( \ Exception $ e ) { if ( $ e instanceof NotFoundHttpException ) { $ responseContent = $ this -> twig ( ) -> render ( 'Default\404.twig' ) ; $ response = new Response ( $ responseContent , 404 ) ; } else { $ responseContent = $ this -> twig ( ) -> render ( 'Default\500.twig' , array ( 'error...
404 and 500 error page for non debug mode
11,790
public function setMessage ( $ type , $ content ) { $ message = new \ stdClass ; $ message -> mt = $ type ; $ message -> content = $ content ; $ messages = $ this -> session ( ) -> get ( 'messages' , array ( ) ) ; $ messages [ ] = $ message ; $ this -> session ( ) -> set ( 'messages' , $ messages ) ; }
Sets a user message to present after reload or redirect .
11,791
public function hasErrorMessages ( ) { $ messages = $ this -> getMessages ( ) ; foreach ( $ messages as $ message ) { if ( $ message -> mt == 'error' ) { return true ; } } return false ; }
Checks into the message bag if there is some error message . Type == error
11,792
public function attachFiles ( $ id , $ table , $ files ) { foreach ( $ files as $ file ) { if ( ! empty ( $ file ) ) { $ this -> attachFile ( $ id , $ table , $ file ) ; } } }
It will attach the array of files to the entity .
11,793
public function attachFile ( $ id , $ table , \ Symfony \ Component \ HttpFoundation \ File \ UploadedFile $ file ) { $ newFileName = md5 ( microtime ( ) . '.' . strtolower ( $ file -> getClientOriginalExtension ( ) ) ) ; $ relativePath = $ table . '/' . date ( 'Y/m/d' ) ; $ relativeFilePath = $ relativePath . '/' . $ ...
It will attach the file .
11,794
public function setResponseCookie ( $ response , $ name , $ value = null , $ expiration = 0 ) { $ expiration = 1 ; if ( $ expiration == 0 ) { $ expiration = 30 ; } if ( is_numeric ( $ expiration ) ) { $ expiration = $ expiration ; } $ response = FigResponseCookies :: set ( $ response , SetCookie :: create ( $ name ) ->...
Set New Response Cookie
11,795
public function modifyResponseCookie ( $ response , $ name , $ value = null , $ expiration = 0 ) { $ expiration = 1 ; if ( $ expiration == 0 ) { $ expiration = 30 ; } if ( is_numeric ( $ expiration ) ) { $ expiration = $ expiration ; } $ modify = function ( SetCookie $ setCookie ) { $ value = $ setCookie -> getValue ( ...
Modify Response Cookie
11,796
public function setRequestCookie ( $ request , $ name , $ value = null ) { if ( empty ( $ name ) ) { return false ; } $ request = FigRequestCookies :: set ( $ request , Cookie :: create ( $ name , $ value ) ) ; return $ request ; }
Set New Request Cookie
11,797
public function modifyRequestCookie ( $ request , $ name , $ value = null ) { $ modify = function ( Cookie $ cookie ) { $ value = $ cookie -> getValue ( ) ; return $ cookie -> withValue ( $ value ) ; } ; $ request = FigRequestCookies :: modify ( $ request , $ name , $ modify ) ; return $ request ; }
Modify Request Cookie
11,798
public function move ( $ destination , $ newName = '' ) { $ source = $ this -> file [ 'tmp_name' ] ; if ( $ destination != '' && substr ( $ destination , - 1 ) != '/' ) { $ destination .= '/' ; } if ( ! empty ( $ newName ) ) { $ target = $ destination . $ newName ; } else { $ target = $ destination . $ this -> file [ '...
Move file from temporary to actual location
11,799
protected function translateToUrlEncodedPath ( $ generatedPathAsUtf8 ) { $ iso88591Path = explode ( '/' , $ generatedPathAsUtf8 ) ; foreach ( $ iso88591Path as & $ part ) { if ( substr ( $ part , - 1 ) == ':' ) { continue ; } $ subparts = explode ( '#' , $ part ) ; if ( extension_loaded ( 'iconv' ) ) { $ subparts [ 0 ]...
Translates the provided path with UTF - 8 characters into a web - and windows - safe variant .