idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
12,100
public function iShouldGet ( PyStringNode $ string ) { if ( $ this -> getOutput ( ) != trim ( $ string -> getRaw ( ) ) ) { throw new \ Exception ( "Actual output is:\n" . $ this -> getOutput ( ) ) ; } }
Verifies whether the output of an iRun When is equal to the given .
12,101
public function theExitCodeShouldBeZero ( ) { if ( $ this -> getReturnCode ( ) != 0 ) { throw new \ Exception ( 'Return code was ' . $ this -> getReturnCode ( ) . ' with output ' . $ this -> getOutput ( ) . $ this -> process -> getOutput ( ) ) ; } }
Verifies whether the return code was 0 and thus execution was a success .
12,102
protected function get_required ( \ WP_Post $ post = null ) { if ( current_user_can ( 'edit_posts' ) ) { $ url = admin_url ( 'post-new.php?post_type=' . $ this -> post_type ) ; $ post_type_obj = get_post_type_object ( $ this -> post_type ) ; $ tip = esc_html ( sprintf ( $ this -> __ ( 'Add new %s' ) , $ post_type_obj -> labels -> name ) ) ; $ input = <<<HTML<a href="{$url}" data-tooltip-title="{$tip}"><i class="dashicons dashicons-plus-alt"></i></a>HTML ; return $ input . parent :: get_required ( $ post ) ; } else { return parent :: get_required ( $ post ) ; } }
Add button before requried
12,103
protected function get_prepopulates ( $ data ) { $ json = [ ] ; foreach ( $ data as $ post ) { $ json [ ] = [ 'id' => $ post -> ID , 'name' => $ post -> post_title , ] ; } return $ json ; }
Get prepopulated data
12,104
function mime ( $ file ) { if ( preg_match ( '/\w+$/' , $ file , $ ext ) ) { $ map = array ( 'au' => 'audio/basic' , 'avi' => 'video/avi' , 'bmp' => 'image/bmp' , 'bz2' => 'application/x-bzip2' , 'css' => 'text/css' , 'dtd' => 'application/xml-dtd' , 'doc' => 'application/msword' , 'gif' => 'image/gif' , 'gz' => 'application/x-gzip' , 'hqx' => 'application/mac-binhex40' , 'html?' => 'text/html' , 'jar' => 'application/java-archive' , 'jpe?g' => 'image/jpeg' , 'js' => 'application/x-javascript' , 'midi' => 'audio/x-midi' , 'mp3' => 'audio/mpeg' , 'mpe?g' => 'video/mpeg' , 'ogg' => 'audio/vorbis' , 'pdf' => 'application/pdf' , 'png' => 'image/png' , 'ppt' => 'application/vnd.ms-powerpoint' , 'ps' => 'application/postscript' , 'qt' => 'video/quicktime' , 'ram?' => 'audio/x-pn-realaudio' , 'rdf' => 'application/rdf' , 'rtf' => 'application/rtf' , 'sgml?' => 'text/sgml' , 'sit' => 'application/x-stuffit' , 'svg' => 'image/svg+xml' , 'swf' => 'application/x-shockwave-flash' , 'tgz' => 'application/x-tar' , 'tiff' => 'image/tiff' , 'txt' => 'text/plain' , 'wav' => 'audio/wav' , 'xls' => 'application/vnd.ms-excel' , 'xml' => 'application/xml' , 'zip' => 'application/x-zip-compressed' ) ; foreach ( $ map as $ key => $ val ) if ( preg_match ( '/' . $ key . '/' , strtolower ( $ ext [ 0 ] ) ) ) return $ val ; } return 'application/octet-stream' ; }
Detect MIME type using file extension
12,105
public function actionIndex ( ) { $ searchModel = new MessageSearch ; $ dataProvider = $ searchModel -> search ( Yii :: $ app -> request -> getQueryParams ( ) ) ; return $ this -> render ( 'index' , compact ( 'dataProvider' , 'searchModel' ) ) ; }
Lists all Message models .
12,106
public function actionFastUpdate ( $ id ) { Message :: updateAll ( [ 'translation' => Yii :: $ app -> request -> post ( 'translation' ) ] , [ 'id' => $ id , 'language' => Yii :: $ app -> request -> post ( 'language' ) ] ) ; }
Fast translation update .
12,107
protected function findModel ( $ id ) { if ( ( $ model = Product :: findOne ( $ id ) ) !== null ) { return $ model ; } else { throw new NotFoundHttpException ( t ( 'app' , 'The requested page does not exist.' ) ) ; } }
Finds the Product model based on its primary key value . If the model is not found a 404 HTTP exception will be thrown .
12,108
protected function requestXml ( $ origin , $ path ) { $ xml = simplexml_load_string ( $ this -> requestContent ( $ origin , $ path ) , "SimpleXMLElement" , LIBXML_NOERROR ) ; if ( false == $ xml ) { $ url = rtrim ( $ origin , '/' ) . '/' . ltrim ( $ path , '/' ) ; throw new \ UnexpectedValueException ( sprintf ( 'The PEAR channel at ' . $ origin . ' is broken. (Invalid XML at file `%s`)' , $ path ) ) ; } return $ xml ; }
Read xml content from remote filesystem
12,109
public function checkVars ( ) { $ http = eZHTTPTool :: instance ( ) ; $ user = eZUser :: currentUser ( ) ; $ isAnon = $ user -> isAnonymous ( ) ; $ status = true ; foreach ( $ this -> fields as $ field => $ fieldSetup ) { $ fieldPostName = $ fieldSetup [ self :: VARNAME ] ; $ this -> setFieldValue ( $ field , $ fieldPostName ) ; if ( ! $ this -> isVariableRequired ( $ field ) ) { continue ; } else { $ fieldRequired = $ fieldSetup [ self :: REQUIRED ] == 'true' ? true : false ; $ fieldExists = $ http -> hasPostVariable ( $ fieldPostName ) ; if ( $ fieldRequired && ! $ fieldExists ) { $ status = false ; $ this -> validationMessage [ $ field ] = ezpI18n :: tr ( 'ezcomments/comment/add' , '%1 is missing.' , null , array ( $ field ) ) ; continue ; } else if ( $ fieldExists ) { $ val = $ http -> postVariable ( $ fieldPostName ) ; if ( $ fieldRequired && empty ( $ val ) ) { $ status = false ; $ this -> validationMessage [ $ field ] = ezpI18n :: tr ( 'ezcomments/comment/add' , 'The field [%1] is empty.' , null , array ( $ field ) ) ; continue ; } else { $ validationResult = $ this -> validateField ( $ field , $ val ) ; if ( $ validationResult !== true ) { $ status = false ; $ this -> validationMessage [ $ field ] = $ validationResult ; continue ; } } } } } $ this -> validationStatus = $ status ; return $ status ; }
check variable from client
12,110
public function fillObject ( $ comment , $ fieldNames = null ) { $ filledFields = $ this -> fields ; if ( ! is_null ( $ fieldNames ) && is_array ( $ fieldNames ) ) { $ filledFields = array ( ) ; foreach ( $ fieldNames as $ fieldName ) { $ filledFields [ $ fieldName ] = $ this -> fields [ $ fieldName ] ; } } foreach ( $ filledFields as $ field => $ fieldSetup ) { $ attributeName = $ fieldSetup [ self :: ATTRIBUTENAME ] ; if ( ! is_null ( $ attributeName ) ) { $ fieldValue = $ this -> fieldValues [ $ field ] ; $ comment -> setAttribute ( $ attributeName , $ fieldValue ) ; } } }
Fill field to comment object
12,111
public function addListenerForEvent ( $ eventClassName , $ listener ) { if ( FALSE === array_key_exists ( $ eventClassName , $ this -> eventMap ) ) { $ this -> eventMap [ $ eventClassName ] = [ ] ; } $ this -> eventMap [ $ eventClassName ] [ ] = $ listener ; }
Adds a new listener for an event .
12,112
public function getListenersForEvent ( $ eventClassName ) { if ( FALSE === array_key_exists ( $ eventClassName , $ this -> eventMap ) ) { return [ ] ; } return $ this -> eventMap [ $ eventClassName ] ; }
Gets all listeners for an event .
12,113
public function view ( $ name , array $ context = [ ] ) { $ context += [ 'current_url' => $ this -> getRequest ( ) -> getUri ( ) ] ; if ( method_exists ( $ this , 'flash' ) ) { $ context += [ 'flash' => $ this -> flash ( ) ] ; } $ response = $ this -> getViewer ( ) -> render ( $ this -> getResponse ( ) , $ name , $ context ) ; $ this -> setResponse ( $ response ) ; }
View rendered template
12,114
public function getCellDataForColumnName ( $ columnName ) { return Extractor :: extract ( $ this -> _data , $ this -> _dataGrid -> getColumn ( $ columnName ) -> getCellAccessor ( ) ) ; }
Get the cell accessor from the DataGridColumn and extract the data from the row
12,115
public function matchIdentityRoles ( array $ roles ) : bool { $ identityRoles = $ this -> getIdentityRoles ( ) ; if ( empty ( $ identityRoles ) ) { return false ; } $ roleNames = [ ] ; foreach ( $ roles as $ role ) { $ roleNames [ ] = $ role instanceof RoleInterface ? $ role -> getName ( ) : ( string ) $ role ; } $ identityRoleNames = [ ] ; foreach ( $ this -> flattenRoles ( $ identityRoles ) as $ role ) { $ identityRoleNames [ ] = $ role -> getName ( ) ; } return count ( array_intersect ( $ roleNames , $ identityRoleNames ) ) > 0 ; }
Check if the given roles match one of the identity roles
12,116
public function get_root_path ( $ repository ) { if ( \ is_string ( $ repository ) ) { $ repository = $ this -> repository ( $ repository ) ; } if ( ! empty ( $ repository ) && ! empty ( $ repository [ 'bbn_path' ] ) ) { $ repository_path = ! empty ( $ repository [ 'path' ] ) ? '/' . $ repository [ 'path' ] : '' ; $ path = self :: decipher_path ( $ repository [ 'bbn_path' ] . $ repository_path ) . '/' ; return \ bbn \ str :: parse_path ( $ path ) ; } return false ; }
Gets the real root path from a repository s id as recorded in the options .
12,117
public function repositories ( string $ code = '' ) { $ all = $ this -> options -> full_soptions ( $ this -> options -> from_code ( 'PATHS' , 'ide' , 'appui' ) ) ; $ cats = [ ] ; $ r = [ ] ; foreach ( $ all as $ a ) { if ( \ defined ( $ a [ 'bbn_path' ] ) ) { $ k = $ a [ 'bbn_path' ] . '/' . ( $ a [ 'code' ] === '/' ? '' : $ a [ 'code' ] ) ; if ( ! isset ( $ cats [ $ a [ 'id_alias' ] ] ) ) { unset ( $ a [ 'alias' ] [ 'cfg' ] ) ; $ cats [ $ a [ 'id_alias' ] ] = $ a [ 'alias' ] ; } unset ( $ a [ 'cfg' ] ) ; unset ( $ a [ 'alias' ] ) ; $ r [ $ k ] = $ a ; $ r [ $ k ] [ 'title' ] = $ r [ $ k ] [ 'text' ] ; $ r [ $ k ] [ 'alias_code' ] = $ cats [ $ a [ 'id_alias' ] ] [ 'code' ] ; if ( ! empty ( $ cats [ $ a [ 'id_alias' ] ] [ 'tabs' ] ) ) { $ r [ $ k ] [ 'tabs' ] = $ cats [ $ a [ 'id_alias' ] ] [ 'tabs' ] ; } else if ( ! empty ( $ cats [ $ a [ 'id_alias' ] ] [ 'extensions' ] ) ) { $ r [ $ k ] [ 'extensions' ] = $ cats [ $ a [ 'id_alias' ] ] [ 'extensions' ] ; } unset ( $ r [ $ k ] [ 'alias' ] ) ; } } if ( $ code ) { return isset ( $ r [ $ code ] ) ? $ r [ $ code ] : false ; } return $ r ; }
Makes the repositories configurations .
12,118
public function repository_from_url ( string $ url , bool $ obj = false ) { $ repository = '' ; $ repositories = $ this -> repositories ( ) ; foreach ( $ repositories as $ i => $ d ) { if ( ( strpos ( $ url , $ i ) === 0 ) && ( \ strlen ( $ i ) > \ strlen ( $ repository ) ) ) { $ repository = $ i ; } } if ( ! empty ( $ repository ) ) { return empty ( $ obj ) ? $ repository : $ repositories [ $ repository ] ; } return false ; }
Returns the repository s name or object from an URL .
12,119
public function real_to_url ( string $ file ) { foreach ( $ this -> repositories ( ) as $ i => $ d ) { if ( ( $ root = $ this -> get_root_path ( $ d ) ) && ( strpos ( $ file , $ root ) === 0 ) ) { $ res = $ i ; $ bits = explode ( '/' , substr ( $ file , \ strlen ( $ root ) ) ) ; if ( ! empty ( $ d [ 'tabs' ] ) ) { $ tab_path = array_shift ( $ bits ) ; $ fn = array_pop ( $ bits ) ; $ ext = \ bbn \ str :: file_ext ( $ fn ) ; $ fn = \ bbn \ str :: file_ext ( $ fn , 1 ) [ 0 ] ; $ res .= implode ( '/' , $ bits ) ; foreach ( $ d [ 'tabs' ] as $ k => $ t ) { if ( empty ( $ t [ 'fixed' ] ) && ( $ t [ 'path' ] === $ tab_path . '/' ) ) { $ res .= "/$fn/$t[url]" ; break ; } } } else { $ res .= implode ( '/' , $ bits ) ; } return \ bbn \ str :: parse_path ( $ res ) ; } } return false ; }
Returns the file s URL from the real file s path .
12,120
private function connection__predis ( ) { $ args = [ ] ; foreach ( array_keys ( $ this -> verified_params ) as $ key ) { if ( $ key == 'redistype' || ! $ this -> $ key ) continue ; $ args [ substr ( $ key , 5 ) ] = $ this -> $ key ; } try { $ this -> connection = new \ Predis \ Client ( $ args ) ; $ this -> connection -> ping ( ) ; return $ this -> connection_open_ok ( ) ; } catch ( \ Predis \ Connection \ ConnectionException $ e ) { return $ this -> connection_open_fail ( $ e -> getMessage ( ) ) ; } }
Open connection with predis .
12,121
private function connection__redis ( ) { $ this -> connection = new \ Redis ( ) ; if ( ! @ $ this -> connection -> connect ( $ this -> redishost , $ this -> redisport , $ this -> redistimeout ) ) return $ this -> connection_open_fail ( ) ; if ( $ this -> redispassword || $ this -> redisdatabase ) { try { if ( $ this -> redispassword ) $ this -> connection -> auth ( $ this -> redispassword ) ; if ( $ this -> redisdatabase ) $ this -> connection -> select ( $ this -> redisdatabase ) ; } catch ( \ RedisException $ e ) { return $ this -> connection_open_fail ( $ e -> getMessage ( ) ) ; } } try { $ this -> connection -> ping ( ) ; } catch ( \ RedisException $ e ) { return $ this -> connection_open_fail ( $ e -> getMessage ( ) ) ; } return $ this -> connection_open_ok ( ) ; }
Open connection with ext - redis .
12,122
private function connection_open_fail ( $ msg = '' ) { $ logline = sprintf ( 'Redis: %s connection failed' , $ this -> redistype ) ; if ( $ msg ) $ logline .= ': ' . $ msg ; $ logline .= ' <- ' . json_encode ( $ this -> verified_params ) ; self :: $ logger -> error ( $ logline ) ; throw new RedisError ( RedisError :: CONNECTION_ERROR , $ logline ) ; }
Throw exception on failing connection .
12,123
public function parseString ( $ str ) { $ parser = ( new \ PhpParser \ ParserFactory ( ) ) -> create ( \ PhpParser \ ParserFactory :: PREFER_PHP7 ) ; $ this -> ast = $ parser -> parse ( $ str ) ; return $ this ; }
Parses a PHP string .
12,124
public function getExactlyOneClass ( $ fileSource ) { if ( count ( $ this -> ast ) !== 1 || $ this -> ast [ 0 ] -> getType ( ) !== "Stmt_Class" ) throw new PhpParserException ( "\"$fileSource\" does not define exactly one class" ) ; return $ this -> ast [ 0 ] ; }
Asserts that the code defines one class and returns it .
12,125
protected function buildResponse ( $ html , ResponseInterface $ response ) { $ body = new Stream ( 'php://memory' , 'w' ) ; $ body -> write ( $ html ) ; $ response = $ response -> withBody ( $ body ) ; return $ response ; }
Builds response instance with HTML body from HTML passed in .
12,126
protected function cacheResponse ( RequestInterface $ request , ResponseInterface $ response ) { $ cacheItem = $ this -> createCacheItem ( $ this -> createKeyFromRequest ( $ request ) ) ; $ value = $ response -> getBody ( ) -> __toString ( ) ; $ cacheItem -> set ( $ value ) ; $ this -> getCacheItemPool ( ) -> save ( $ cacheItem ) ; }
Caches a response by Request & Response .
12,127
public function addElementArray ( $ elementArray ) { if ( ! is_array ( $ elementArray ) ) { return ; } foreach ( $ elementArray as $ elementName => $ content ) { $ this -> addElement ( $ elementName , $ content ) ; } }
Set multiple feed elements from an array . Elements which have attributes cannot be added by this method
12,128
public function setDate ( $ date ) { if ( ! is_numeric ( $ date ) ) { $ date = strtotime ( $ date ) ; } if ( $ this -> version == Eresus_Feed_Writer :: ATOM ) { $ tag = 'updated' ; $ value = date ( DATE_ATOM , $ date ) ; } elseif ( $ this -> version == Eresus_Feed_Writer :: RSS2 ) { $ tag = 'pubDate' ; $ value = date ( DATE_RSS , $ date ) ; } else { $ tag = 'dc:date' ; $ value = date ( "Y-m-d" , $ date ) ; } $ this -> addElement ( $ tag , $ value ) ; }
Set the date element of feed item
12,129
public function setEncloser ( $ url , $ length , $ type ) { $ attributes = array ( 'url' => $ url , 'length' => $ length , 'type' => $ type ) ; $ this -> addElement ( 'enclosure' , '' , $ attributes ) ; }
Set the encloser element of feed item For RSS 2 . 0 only
12,130
static function fetchNotificationList ( $ status = 1 , $ length = null , $ offset = 0 , $ sorts = null ) { $ cond = array ( ) ; if ( is_null ( $ status ) ) { $ cond = null ; } else { $ cond [ 'status' ] = $ status ; } $ limit = array ( ) ; if ( is_null ( $ length ) ) { $ limit = null ; } else { $ limit [ 'offset' ] = $ offset ; $ limit [ 'length' ] = $ length ; } return eZPersistentObject :: fetchObjectList ( self :: definition ( ) , null , $ cond , $ sorts , $ limit ) ; }
Fetch the list of notification
12,131
public static function factory ( $ aOptions ) { if ( $ aOptions instanceof \ Traversable ) $ aOptions = \ Zend \ Stdlib \ ArrayUtils :: iteratorToArray ( $ aOptions ) ; elseif ( ! is_array ( $ aOptions ) ) throw new \ InvalidArgumentException ( __METHOD__ . ' expects an array or Traversable object; received "' . ( is_object ( $ aOptions ) ? get_class ( $ aOptions ) : gettype ( $ aOptions ) ) . '"' ) ; return new static ( new \ TreeLayoutStack \ TemplatingConfiguration ( $ aOptions ) ) ; }
Instantiate a Templating service
12,132
public function buildLayoutTemplate ( \ Zend \ Mvc \ MvcEvent $ oEvent ) { $ oRequest = $ oEvent -> getRequest ( ) ; if ( ! ( $ oRequest instanceof \ Zend \ Http \ Request ) || $ oRequest -> isXmlHttpRequest ( ) || ( ( $ oView = $ oEvent -> getResult ( ) ) instanceof \ Zend \ View \ Model \ ModelInterface && $ oView -> terminate ( ) ) ) return $ this ; $ this -> setCurrentEvent ( $ oEvent ) ; if ( ( $ oRouter = $ this -> getCurrentEvent ( ) -> getRouteMatch ( ) ) instanceof \ Zend \ Mvc \ Router \ RouteMatch ) $ sModule = current ( explode ( '\\' , $ oRouter -> getParam ( 'controller' ) ) ) ; if ( empty ( $ sModule ) ) $ sModule = \ TreeLayoutStack \ TemplatingConfiguration :: DEFAULT_LAYOUT_TREE ; try { $ oTemplate = $ this -> getConfiguration ( ) -> hasLayoutTreeForModule ( $ sModule ) ? $ this -> getConfiguration ( ) -> getLayoutTreeForModule ( $ sModule ) : $ this -> getConfiguration ( ) -> getLayoutTreeForModule ( \ TreeLayoutStack \ TemplatingConfiguration :: DEFAULT_LAYOUT_TREE ) ; $ sTemplate = $ oTemplate -> getConfiguration ( ) -> getTemplate ( ) ; if ( is_callable ( $ sTemplate ) ) $ sTemplate = $ sTemplate ( $ this -> getCurrentEvent ( ) ) ; $ oEvent -> setViewModel ( $ this -> setChildrenToView ( $ oEvent -> getViewModel ( ) -> setTemplate ( $ sTemplate ) , $ oTemplate -> getChildren ( ) ) ) ; } catch ( \ Exception $ oException ) { throw new \ RuntimeException ( 'Error occured during building layout template process : ' . $ oException -> getMessage ( ) , $ oException -> getCode ( ) , $ oException ) ; } return $ this -> unsetCurrentEvent ( ) ; }
Define layout template
12,133
public static function fromPackageFile ( $ composerJson ) { if ( file_exists ( $ composerJson ) === false ) { throw new ComposerJsonNotFoundException ( "File {$composerJson} not found." ) ; } $ config = Config :: load ( $ composerJson ) ; $ autoload = $ config -> get ( 'autoload.psr-4' ) ; $ composerJsonDirectory = dirname ( $ composerJson ) ; $ keys = array_keys ( $ autoload ) ; $ namespace = array_shift ( $ keys ) ; $ values = array_values ( $ autoload ) ; $ namespaceDirectory = array_shift ( $ values ) ; $ namespaceDirectory = realpath ( $ composerJsonDirectory . '/' . $ namespaceDirectory ) ; return new self ( $ namespace , $ namespaceDirectory ) ; }
Create a new matcher package from composer . json
12,134
public function setClient ( \ Gpupo \ CommonSchema \ ORM \ Entity \ Application \ API \ OAuth \ Client \ Client $ client = null ) { $ this -> client = $ client ; return $ this ; }
Set client .
12,135
private function check_controller_hash_tmp_file ( ) { if ( is_writable ( dirname ( $ this -> controllers_hash_file ) ) ) { App :: uses ( 'File' , 'Utility' ) ; $ file = new File ( $ this -> controllers_hash_file , true ) ; return $ file -> exists ( ) ; } else { $ this -> Session -> setFlash ( sprintf ( __d ( 'acl' , 'the %s directory is not writable' ) , dirname ( $ this -> controllers_hash_file ) ) , 'Risto.flash_error' , null , 'plugin_acl' ) ; return false ; } }
Check if the file containing the stored controllers hashes can be created and create it if it does not exist
12,136
public function set_display_name ( $ model_classname , $ field_expression ) { $ model_instance = $ this -> get_model_instance ( $ model_classname ) ; $ schema = $ model_instance -> schema ( ) ; if ( array_key_exists ( $ field_expression , $ schema ) || array_key_exists ( str_replace ( $ model_classname . '.' , '' , $ field_expression ) , $ schema ) || array_key_exists ( $ field_expression , $ model_instance -> virtualFields ) ) { if ( strpos ( $ field_expression , $ model_classname . '.' ) === 0 ) { $ field_expression = str_replace ( $ model_classname . '.' , '' , $ field_expression ) ; } return $ field_expression ; } else { $ this -> controller -> { $ model_classname } -> virtualFields [ 'alaxos_acl_display_name' ] = $ field_expression ; return 'alaxos_acl_display_name' ; } }
Check if a given field_expression is an existing fieldname for the given model
12,137
private function get_model_instance ( $ model_classname ) { if ( ! isset ( $ this -> controller -> { $ model_classname } ) ) { $ model_instance = ClassRegistry :: init ( $ model_classname ) ; } else { $ model_instance = $ this -> controller -> { $ model_classname } ; } return $ model_instance ; }
Return an instance of the given model name
12,138
public function get_stored_controllers_hashes ( ) { $ file = new File ( $ this -> controllers_hash_file ) ; $ file_content = $ file -> read ( ) ; if ( ! empty ( $ file_content ) ) { $ stored_controller_hashes = unserialize ( $ file_content ) ; } else { $ stored_controller_hashes = array ( ) ; } return $ stored_controller_hashes ; }
return the stored array of controllers hashes
12,139
public function get_current_controllers_hashes ( ) { $ controllers = $ this -> AclReflector -> get_all_controllers ( ) ; $ current_controller_hashes = array ( ) ; foreach ( $ controllers as $ controller ) { $ ctler_file = new File ( $ controller [ 'file' ] ) ; $ current_controller_hashes [ $ controller [ 'name' ] ] = $ ctler_file -> md5 ( ) ; } return $ current_controller_hashes ; }
return an array of all controllers hashes
12,140
public function get_missing_acos ( $ update_hash_file = true ) { if ( $ this -> check_controller_hash_tmp_file ( ) ) { $ missing_aco_nodes = array ( ) ; $ stored_controller_hashes = $ this -> get_stored_controllers_hashes ( ) ; $ current_controller_hashes = $ this -> get_current_controllers_hashes ( ) ; if ( $ update_hash_file ) { $ file = new File ( $ this -> controllers_hash_file ) ; $ file -> write ( serialize ( $ current_controller_hashes ) ) ; } $ updated_controllers = array_keys ( Set :: diff ( $ current_controller_hashes , $ stored_controller_hashes ) ) ; if ( ! empty ( $ updated_controllers ) ) { $ aco = & $ this -> Acl -> Aco ; foreach ( $ updated_controllers as $ controller_name ) { if ( $ controller_name !== 'App' ) { $ controller_classname = $ this -> AclReflector -> get_controller_classname ( $ controller_name ) ; $ methods = $ this -> AclReflector -> get_controller_actions ( $ controller_classname ) ; $ aco = & $ this -> Acl -> Aco ; foreach ( $ methods as $ method ) { $ methodNode = $ aco -> node ( 'controllers/' . $ controller_name . '/' . $ method ) ; if ( empty ( $ methodNode ) ) { $ missing_aco_nodes [ ] = $ controller_name . '/' . $ method ; } } } } } return $ missing_aco_nodes ; } }
Get a list of plugins controllers and actions that don t have any corresponding ACO . To run faster the method only checks controllers that have not already been checked or that have been modified .
12,141
public function setStatus ( array $ params ) { if ( ! isset ( $ params [ 'identifier' ] ) ) { throw new MissingArgumentException ( 'identifier' ) ; } if ( ! isset ( $ params [ 'status' ] ) ) { throw new MissingArgumentException ( 'status' ) ; } return $ this -> post ( 'set_status' , $ params ) ; }
Updates the user status using the current signed in identity provider .
12,142
public function createTable ( ) { $ this -> getConnection ( ) ; switch ( $ this -> driver ) { case 'mysql' : $ sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY, $this->usernameCol VARBINARY(256) NOT NULL, $this->lastUsedCol INTEGER UNSIGNED NOT NULL, $this->expiredCol INTEGER UNSIGNED) COLLATE utf8_bin, ENGINE = InnoDB" ; break ; case 'sqlite' : $ sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->usernameCol TEXT NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)" ; break ; case 'pgsql' : $ sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)" ; break ; case 'oci' : $ sql = "CREATE TABLE $this->table ($this->idCol VARCHAR2(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)" ; break ; case 'sqlsrv' : $ sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)" ; break ; default : throw new \ DomainException ( sprintf ( 'Creating the session table is currently not implemented for PDO driver "%s".' , $ this -> driver ) ) ; } try { $ this -> getConnection ( ) -> exec ( $ sql ) ; } catch ( \ PDOException $ e ) { throw new \ RuntimeException ( sprintf ( 'PDOException was thrown when trying to create sessions info table: %s' , $ e -> getMessage ( ) ) , 0 , $ e ) ; } }
Creates the table to store sessions which can be called once for setup .
12,143
public function connectToServer ( $ address , $ options = array ( ) ) { $ parameters = NULL ; if ( array_key_exists ( 'port' , $ options ) ) { $ parameters = ':' . $ options [ 'port' ] ; } if ( array_key_exists ( 'password' , $ options ) ) { $ parameters .= '/' . $ options [ 'password' ] ; } return $ this -> protocol . 'connect/' . $ address . $ parameters ; }
Generates a link to connecto the specified server
12,144
public function openSteamPage ( $ page , $ parameter = NULL ) { if ( in_array ( $ page , $ this -> steamPages ) ) { return $ this -> protocol . 'url/' . $ page . '/' . $ parameter ; } }
Generates a link to open the specified named page
12,145
protected function findSource ( ) { $ stack = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT ) ; $ sources = [ ] ; foreach ( $ stack as $ index => $ trace ) { $ sources [ ] = $ this -> parseTrace ( $ index , $ trace ) ; } return array_filter ( $ sources ) ; }
Use a backtrace to search for the origins of the query .
12,146
protected function parseTrace ( $ index , array $ trace ) { $ frame = ( object ) [ 'index' => $ index , 'namespace' => null , 'name' => null , 'line' => isset ( $ trace [ 'line' ] ) ? $ trace [ 'line' ] : '?' , ] ; if ( isset ( $ trace [ 'function' ] ) && $ trace [ 'function' ] == 'substituteBindings' ) { $ frame -> name = 'Route binding' ; return $ frame ; } if ( isset ( $ trace [ 'class' ] ) && isset ( $ trace [ 'file' ] ) && strpos ( $ trace [ 'file' ] , DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'laravel' . DIRECTORY_SEPARATOR . 'framework' ) === false && strpos ( $ trace [ 'file' ] , DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'barryvdh' . DIRECTORY_SEPARATOR . 'laravel-debugbar' ) === false ) { $ file = $ trace [ 'file' ] ; if ( isset ( $ trace [ 'object' ] ) && is_a ( $ trace [ 'object' ] , 'Twig_Template' ) ) { list ( $ file , $ frame -> line ) = $ this -> getTwigInfo ( $ trace ) ; } elseif ( strpos ( $ file , storage_path ( ) ) !== false ) { $ hash = pathinfo ( $ file , PATHINFO_FILENAME ) ; if ( ! $ frame -> name = $ this -> findViewFromHash ( $ hash ) ) { $ frame -> name = $ hash ; } $ frame -> namespace = 'view' ; return $ frame ; } elseif ( strpos ( $ file , 'Middleware' ) !== false ) { $ frame -> name = $ this -> findMiddlewareFromFile ( $ file ) ; if ( $ frame -> name ) { $ frame -> namespace = 'middleware' ; } else { $ frame -> name = $ this -> normalizeFilename ( $ file ) ; } return $ frame ; } $ frame -> name = $ this -> normalizeFilename ( $ file ) ; return $ frame ; } return false ; }
Parse a trace element from the backtrace stack .
12,147
public function find ( $ key , $ default = null ) { $ key = $ this -> formatKey ( $ key ) ; $ headers = array_get ( $ this -> headers , $ key , $ default ) ; if ( is_array ( $ headers ) ) { $ headers = array_pop ( $ headers ) ; } return $ headers ; }
Find the last added header .
12,148
public function set ( $ key , $ value ) { $ key = $ this -> formatKey ( $ key ) ; array_set ( $ this -> headers , $ key , [ $ value ] ) ; }
Replace all previous headers with this one .
12,149
public function get ( $ key ) { $ key = $ this -> formatKey ( $ key ) ; return array_get ( $ this -> headers , $ key , [ ] ) ; }
Get all headers by key .
12,150
public function has ( $ key ) { $ key = $ this -> formatKey ( $ key ) ; return array_has ( $ this -> headers , $ key ) ; }
Check if there are any headers .
12,151
public function remove ( $ key ) { $ key = $ this -> formatKey ( $ key ) ; array_remove ( $ this -> headers , $ key ) ; }
Remove all registered headers .
12,152
public function toFlatArray ( ) { $ array = [ ] ; foreach ( $ this -> headers as $ key => $ headers ) { foreach ( $ headers as $ header ) { $ array [ ] = $ this -> formatHeader ( $ key , $ header ) ; } } return $ array ; }
Get a list of formatted header strings .
12,153
protected function toArray ( $ data ) { if ( is_array ( $ data ) ) { return $ data ; } if ( is_object ( $ data ) ) { if ( method_exists ( $ data , 'toArray' ) ) { return $ data -> toArray ( ) ; } if ( $ data instanceof \ Traversable ) { return iterator_to_array ( $ data ) ; } } return ( array ) $ data ; }
Convert a result set to an array
12,154
public static function parseCookieParts ( array $ cookieParts ) { $ cookie = '' ; foreach ( $ cookieParts as $ key => $ val ) { $ cookie .= $ key . '=' . rawurlencode ( $ val ) . ';' ; } $ cookie = trim ( $ cookie , ';' ) ; return $ cookie ; }
Takes an array of cookie parts and returns an urlencoded string ready to send
12,155
public function register ( Application $ app ) { $ config = $ app [ 'config' ] ; $ app [ 'translator.locale' ] = $ config -> getTranslator ( ) -> getLocale ( ) ; $ app [ 'translator' ] = $ app -> share ( function ( $ app ) { $ translator = new Translator ( ) ; $ translator -> setLocale ( $ app [ 'translator.locale' ] ) ; return $ translator ; } ) ; }
Registers the translator using the currently active locale .
12,156
public function clientGetById ( $ clid ) { if ( ! array_key_exists ( $ clid , $ this -> clientList ( ) ) ) { throw new Exception ( "invalid clientID" , 0x200 ) ; } return $ this -> clientList [ intval ( $ clid ) ] ; }
Returns the Client object matching the given ID .
12,157
protected function lazyLoad ( $ eventName ) { if ( isset ( $ this -> listenerIds [ $ eventName ] ) ) { foreach ( $ this -> listenerIds [ $ eventName ] as $ args ) { list ( $ serviceId , $ method , $ priority ) = $ args ; $ listener = $ this -> container -> get ( $ serviceId ) ; $ key = $ serviceId . '.' . $ method ; if ( ! isset ( $ this -> listeners [ $ eventName ] [ $ key ] ) ) { $ this -> addListener ( $ eventName , array ( $ listener , $ method ) , $ priority ) ; } elseif ( $ listener !== $ this -> listeners [ $ eventName ] [ $ key ] ) { parent :: removeListener ( $ eventName , array ( $ this -> listeners [ $ eventName ] [ $ key ] , $ method ) ) ; $ this -> addListener ( $ eventName , array ( $ listener , $ method ) , $ priority ) ; } $ this -> listeners [ $ eventName ] [ $ key ] = $ listener ; } } }
Lazily loads listeners for this event from the dependency injection container .
12,158
private function helpers ( $ handlebars ) { $ helpers = $ this -> default_helpers ( ) ; $ helpers = apply_filters ( 'caldera_metaplate_handlebars_helpers' , $ helpers , $ handlebars ) ; $ handlebars = new helper_loader ( $ handlebars , $ helpers ) ; if ( isset ( $ handlebars -> handlebars ) ) { $ handlebars = $ handlebars -> handlebars ; } return $ handlebars ; }
Register helpers .
12,159
private function initTypes ( ) { $ this -> types = [ ] ; foreach ( $ this -> loadTypes ( ) as $ type ) { if ( ! $ type instanceof BlockTypeInterface ) { throw new Exception \ UnexpectedTypeException ( $ type , 'Oro\Component\Layout\BlockTypeInterface' ) ; } $ this -> types [ $ type -> getName ( ) ] = $ type ; } }
Initializes block types .
12,160
private function initTypeExtensions ( ) { $ this -> typeExtensions = [ ] ; foreach ( $ this -> loadTypeExtensions ( ) as $ extension ) { if ( ! $ extension instanceof BlockTypeExtensionInterface ) { throw new Exception \ UnexpectedTypeException ( $ extension , 'Oro\Component\Layout\BlockTypeExtensionInterface' ) ; } $ type = $ extension -> getExtendedType ( ) ; $ this -> typeExtensions [ $ type ] [ ] = $ extension ; } }
Initializes block type extensions .
12,161
private function initLayoutUpdates ( ContextInterface $ context ) { $ loadedLayoutUpdates = $ this -> loadLayoutUpdates ( $ context ) ; foreach ( $ loadedLayoutUpdates as $ id => $ layoutUpdates ) { if ( ! is_string ( $ id ) ) { throw new Exception \ UnexpectedTypeException ( $ id , 'string' , 'layout item id' ) ; } if ( ! is_array ( $ layoutUpdates ) ) { throw new Exception \ UnexpectedTypeException ( $ layoutUpdates , 'array' , sprintf ( 'layout updates for item "%s"' , $ id ) ) ; } foreach ( $ layoutUpdates as $ layoutUpdate ) { if ( ! $ layoutUpdate instanceof LayoutUpdateInterface ) { throw new Exception \ UnexpectedTypeException ( $ layoutUpdate , 'Oro\Component\Layout\LayoutUpdateInterface' ) ; } } } $ this -> layoutUpdates = $ loadedLayoutUpdates ; }
Initializes layout updates .
12,162
private function initContextConfigurators ( ) { $ this -> contextConfigurators = [ ] ; foreach ( $ this -> loadContextConfigurators ( ) as $ configurator ) { if ( ! $ configurator instanceof ContextConfiguratorInterface ) { throw new Exception \ UnexpectedTypeException ( $ configurator , 'Oro\Component\Layout\ContextConfiguratorInterface' ) ; } $ this -> contextConfigurators [ ] = $ configurator ; } }
Initializes layout context configurators .
12,163
private function initDataProviders ( ) { $ this -> dataProviders = [ ] ; foreach ( $ this -> loadDataProviders ( ) as $ name => $ dataProvider ) { $ this -> dataProviders [ $ name ] = $ dataProvider ; } }
Initializes data providers .
12,164
public function create ( $ schema ) { $ types = array_map ( function ( $ column ) { return $ column [ 'name' ] . ':' . $ column [ 'type' ] ; } , $ schema ) ; return implode ( ', ' , $ types ) ; }
Return the argument string to use for the migration command .
12,165
public function next ( ) { $ this -> is -> next ( ) ; if ( $ this -> is -> valid ( ) ) { if ( $ this -> debug ) fprintf ( STDOUT , "> %s\n" , $ this -> is -> current ( ) ) ; return $ this -> is -> current ( ) ; } return false ; }
Get the next character .
12,166
public function init ( ) { parent :: init ( ) ; if ( ! Permission :: check ( "USERS_MANAGE_ACCOUNT" ) ) { Security :: permissionFailure ( ) ; } $ member = Member :: currentUser ( ) ; if ( $ member instanceof Member ) { $ this -> member = $ member ; } }
Perorm setup when this controller is initialised
12,167
public function index ( ) { $ sections = ArrayList :: create ( ) ; $ sections -> push ( ArrayData :: create ( array ( "Title" => "" , "Content" => $ this -> renderWith ( "UsersProfileSummary" , array ( "CurrentUser" => Member :: currentUser ( ) ) ) ) ) ) ; $ this -> extend ( "updateIndexSections" , $ sections ) ; $ this -> customise ( array ( "Title" => _t ( 'Users.ProfileSummary' , 'Profile Summary' ) , "MetaTitle" => _t ( 'Users.ProfileSummary' , 'Profile Summary' ) , "Content" => $ this -> renderWith ( "UsersAccountSections" , array ( "Sections" => $ sections ) ) ) ) ; $ this -> extend ( "onBeforeIndex" ) ; return $ this -> renderWith ( array ( "UserAccount" , "Page" ) ) ; }
Display the currently outstanding orders for the current user
12,168
public function ChangePasswordForm ( ) { $ form = ChangePasswordForm :: create ( $ this , "ChangePasswordForm" ) ; $ form -> Actions ( ) -> find ( "name" , "action_doChangePassword" ) -> addExtraClass ( "btn" ) -> addExtraClass ( "btn-green" ) ; $ cancel_btn = LiteralField :: create ( "CancelLink" , '<a href="' . $ this -> Link ( ) . '" class="btn btn-red">' . _t ( "Users.CANCEL" , "Cancel" ) . '</a>' ) ; $ form -> Actions ( ) -> insertBefore ( $ cancel_btn , "action_doChangePassword" ) ; $ this -> extend ( "updateChangePasswordForm" , $ form ) ; return $ form ; }
Factory for generating a change password form . The form can be expanded using an extension class and calling the updateChangePasswordForm method .
12,169
public function getAccountMenu ( ) { $ menu = ArrayList :: create ( ) ; $ curr_action = $ this -> request -> param ( "Action" ) ; $ menu -> add ( ArrayData :: create ( array ( "ID" => 0 , "Title" => _t ( 'Users.PROFILESUMMARY' , "Profile Summary" ) , "Link" => $ this -> Link ( ) , "LinkingMode" => ( ! $ curr_action ) ? "current" : "link" ) ) ) ; $ menu -> add ( ArrayData :: create ( array ( "ID" => 10 , "Title" => _t ( 'Users.EDITDETAILS' , "Edit account details" ) , "Link" => $ this -> Link ( "edit" ) , "LinkingMode" => ( $ curr_action == "edit" ) ? "current" : "link" ) ) ) ; $ menu -> add ( ArrayData :: create ( array ( "ID" => 30 , "Title" => _t ( 'Users.CHANGEPASSWORD' , "Change password" ) , "Link" => $ this -> Link ( "changepassword" ) , "LinkingMode" => ( $ curr_action == "changepassword" ) ? "current" : "link" ) ) ) ; $ this -> extend ( "updateAccountMenu" , $ menu ) ; return $ menu -> sort ( "ID" , "ASC" ) ; }
Return a list of nav items for managing a users profile . You can add new items to this menu using the updateAccountMenu extension
12,170
public function getDataStructureIdentifierPreProcess ( array $ fieldTca , string $ tableName , string $ fieldName , array $ row ) : array { if ( $ tableName != 'tt_content' || $ fieldName != 'tx_column_layout_column_config' ) { return [ ] ; } return [ 'type' => 'tca' , 'tableName' => $ tableName , 'fieldName' => $ fieldName , 'dataStructureKey' => ColumnLayoutUtility :: getColumnLayoutSettings ( $ row [ '_tx_column_layout_orig_pid' ] ?? $ row [ 'pid' ] ) [ 'flexFormKey' ] ] ; }
Generates a DataStructureIdentifier for the flexform in column configuration field
12,171
public function transform ( ProjectDescriptor $ project , Transformation $ transformation ) { $ structure = $ this -> loadAst ( $ this -> getAstPath ( $ transformation ) ) ; $ proc = $ this -> getXslProcessor ( $ transformation ) ; $ proc -> registerPHPFunctions ( ) ; $ this -> registerDefaultVariables ( $ transformation , $ proc , $ structure ) ; $ this -> setProcessorParameters ( $ transformation , $ proc ) ; $ artifact = $ this -> getArtifactPath ( $ transformation ) ; $ this -> checkForSpacesInPath ( $ artifact ) ; if ( $ transformation -> getQuery ( ) !== '' ) { $ xpath = new \ DOMXPath ( $ structure ) ; $ qry = $ xpath -> query ( $ transformation -> getQuery ( ) ) ; $ count = $ qry -> length ; foreach ( $ qry as $ key => $ element ) { Dispatcher :: getInstance ( ) -> dispatch ( 'transformer.writer.xsl.pre' , PreXslWriterEvent :: createInstance ( $ this ) -> setElement ( $ element ) -> setProgress ( array ( $ key + 1 , $ count ) ) ) ; $ proc -> setParameter ( '' , $ element -> nodeName , $ element -> nodeValue ) ; $ file_name = $ transformation -> getTransformer ( ) -> generateFilename ( $ element -> nodeValue ) ; if ( ! $ artifact ) { $ url = $ this -> generateUrlForXmlElement ( $ project , $ element ) ; if ( $ url === false || $ url [ 0 ] !== DIRECTORY_SEPARATOR ) { continue ; } $ filename = $ transformation -> getTransformer ( ) -> getTarget ( ) . str_replace ( '/' , DIRECTORY_SEPARATOR , $ url ) ; } else { $ filename = str_replace ( '{$' . $ element -> nodeName . '}' , $ file_name , $ artifact ) ; } $ relativeFileName = substr ( $ filename , strlen ( $ transformation -> getTransformer ( ) -> getTarget ( ) ) + 1 ) ; $ proc -> setParameter ( '' , 'root' , str_repeat ( '../' , substr_count ( $ relativeFileName , '/' ) ) ) ; $ this -> writeToFile ( $ filename , $ proc , $ structure ) ; } } else { if ( substr ( $ transformation -> getArtifact ( ) , 0 , 1 ) == '$' ) { $ variable_name = substr ( $ transformation -> getArtifact ( ) , 1 ) ; $ this -> xsl_variables [ $ variable_name ] = $ proc -> transformToXml ( $ structure ) ; } else { $ relativeFileName = substr ( $ artifact , strlen ( $ transformation -> getTransformer ( ) -> getTarget ( ) ) + 1 ) ; $ proc -> setParameter ( '' , 'root' , str_repeat ( '../' , substr_count ( $ relativeFileName , '/' ) ) ) ; $ this -> writeToFile ( $ artifact , $ proc , $ structure ) ; } } }
This method combines the structure . xml and the given target template and creates a static html page at the artifact location .
12,172
protected function getXsltUriFromFilename ( $ filename ) { if ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) == 'WIN' && ! \ Phar :: running ( ) ) { $ filename = '/' . $ filename ; } return 'file://' . $ filename ; }
Takes the filename and converts it into a correct URI for XSLTProcessor .
12,173
public function create ( $ inbox = 'INBOX' ) { $ stream = imap_open ( $ this -> connectionString ( $ inbox ) , $ this -> user , $ this -> password ) ; return new Connection ( $ stream ) ; }
Create new IMAP connection
12,174
public function mailboxes ( $ mailboxSearch = '*' , $ withConnection = false ) { $ connectionString = $ this -> connectionString ( ) ; $ stream = imap_open ( $ connectionString , $ this -> user , $ this -> password ) ; $ mailboxes = imap_list ( $ stream , $ connectionString , $ mailboxSearch ) ; if ( $ withConnection ) { return $ mailboxes ; } return array_map ( function ( $ mailbox ) use ( $ connectionString ) { return str_replace ( $ connectionString , '' , $ mailbox ) ; } , $ mailboxes ) ; }
Get a list of mailboxes on the mail server .
12,175
protected function connectionString ( $ inbox = '' ) { return sprintf ( static :: $ connectionFormat , $ this -> host , $ this -> port , $ this -> service , $ this -> enc , $ inbox ) ; }
Make the IMAP connection string from configuration
12,176
public function read ( $ length = 4096 ) { $ data = false ; $ this -> _checkFileOpened ( ) ; if ( $ length > 0 ) { $ data = $ this -> _read ( $ length ) ; } return $ data ; }
Read data from file
12,177
protected function _open ( $ mode ) { $ this -> _fileHandler = @ fopen ( $ this -> _filePath , $ mode ) ; if ( false === $ this -> _fileHandler ) { throw new Mage_Exception ( 'Failed to open file ' . $ this -> _filePath ) ; } }
Implementation of file opening
12,178
protected function _write ( $ data ) { $ result = @ fwrite ( $ this -> _fileHandler , $ data ) ; if ( false === $ result ) { throw new Mage_Exception ( 'Failed to write data to ' . $ this -> _filePath ) ; } }
Implementation of writing data to file
12,179
protected function _read ( $ length ) { $ result = fread ( $ this -> _fileHandler , $ length ) ; if ( false === $ result ) { throw new Mage_Exception ( 'Failed to read data from ' . $ this -> _filePath ) ; } return $ result ; }
Implementation of file reading
12,180
public function generateBody ( ) { $ data = $ this -> noMimeMessage . ezcMailTools :: lineBreak ( ) ; foreach ( $ this -> parts as $ part ) { $ data .= ezcMailTools :: lineBreak ( ) . '--' . $ this -> boundary . ezcMailTools :: lineBreak ( ) ; $ data .= $ part -> generate ( ) ; } $ data .= ezcMailTools :: lineBreak ( ) . '--' . $ this -> boundary . '--' ; return $ data ; }
Returns the generated body for all multipart types .
12,181
public function hasResponsible ( $ user ) { return $ this -> users ( ) -> where ( 'user_id' , $ user -> id ) -> first ( ) -> pivot -> responsible ; }
Returns true if the event have the specified user as responsible .
12,182
public function startDatetime ( ) { $ date = explode ( '-' , $ this -> start_date ) ; $ time = explode ( ':' , $ this -> start_time ) ; $ start_datetime = Carbon :: create ( $ date [ 0 ] , $ date [ 1 ] , $ date [ 2 ] , $ time [ 0 ] , $ time [ 1 ] ) ; return $ start_datetime ; }
Get Carbon start datetime .
12,183
public function endDatetime ( ) { $ date = explode ( '-' , $ this -> end_date ) ; $ time = explode ( ':' , $ this -> end_time ) ; $ end_datetime = Carbon :: create ( $ date [ 0 ] , $ date [ 1 ] , $ date [ 2 ] , $ time [ 0 ] , $ time [ 1 ] ) ; return $ end_datetime ; }
Get Carbon end datetime .
12,184
protected function syn ( ) { $ this -> initTransport ( $ this -> options ) ; $ this -> transport -> setAdapter ( $ this ) ; Profiler :: init ( spl_object_hash ( $ this ) ) ; $ rdy = $ this -> getTransport ( ) -> readLine ( ) ; if ( ! $ rdy -> startsWith ( TeamSpeak3 :: TS3_PROTO_IDENT ) && ! $ rdy -> startsWith ( TeamSpeak3 :: TEA_PROTO_IDENT ) && ! ( defined ( "CUSTOM_PROTO_IDENT" ) && $ rdy -> startsWith ( CUSTOM_PROTO_IDENT ) ) ) { throw new AdapterException ( "invalid reply from the server (" . $ rdy . ")" ) ; } Signal :: getInstance ( ) -> emit ( "serverqueryConnected" , $ this ) ; }
Connects the Transport object and performs initial actions on the remote server .
12,185
public function adjust ( Carrier $ carrier = null ) { if ( $ carrier !== null ) { $ this -> carrier = $ carrier ; } if ( ! isset ( $ this -> carrier ) ) { throw new MissingCarrier ( 'Carrier is required to adjust cost' ) ; } $ costs = $ this -> getPossibleCostsPerCarrier ( ) [ $ this -> carrier -> network ] ; foreach ( $ costs as $ i => $ cost ) { if ( $ this -> amount == $ cost ) { break ; } if ( $ this -> amount < $ cost || ! isset ( $ costs [ $ i + 1 ] ) ) { $ this -> amount = $ cost ; break ; } } return $ this ; }
Adjust cost amount for a given carrier
12,186
public function fix ( $ mobileOrCarrier ) { if ( $ mobileOrCarrier instanceof Carrier ) { $ this -> carrier = $ mobileOrCarrier ; } elseif ( $ mobileOrCarrier instanceof Mobile ) { $ this -> carrier = $ mobileOrCarrier -> carrier ; } else { $ this -> carrier = Loader :: mobile ( $ mobileOrCarrier ) -> carrier ; } return $ this -> adjust ( ) ; }
Fix cost by mobile or carrier
12,187
public function apply ( Collection $ collection ) { $ this -> collection = $ collection ; foreach ( $ this -> filters ( ) as $ name => $ value ) { if ( ! method_exists ( $ this , $ name ) ) { continue ; } if ( is_array ( $ value ) or trim ( $ value ) ) { $ this -> collection = $ this -> $ name ( $ value ) ; } else { $ this -> collection = $ this -> $ name ( ) ; } } return $ this -> collection ; }
Apply the filters to the collection .
12,188
private function getFileOrDirectorySettings ( $ settings , $ key ) { $ filesOrDirectories = $ settings -> getOptional ( $ key , array ( ) ) ; if ( ! is_array ( $ filesOrDirectories ) ) $ filesOrDirectories = array ( $ filesOrDirectories ) ; return $ filesOrDirectories ; }
Returns plain settings arrays with file or directory specifications .
12,189
protected function _generateFiles ( ) { foreach ( $ this -> selectedArtifacts as $ artifact ) { $ settings = $ artifact -> getGeneratorSettings ( static :: getKey ( ) ) ; foreach ( $ this -> getFileOrDirectorySettings ( $ settings , "files" ) as $ file ) $ this -> _processFileSpecification ( $ artifact , fphp \ Specification \ FileSpecification :: fromArrayAndSettings ( $ file , $ settings ) ) ; foreach ( $ this -> getFileOrDirectorySettings ( $ settings , "directories" ) as $ directory ) { $ directorySpecification = fphp \ Specification \ DirectorySpecification :: fromArrayAndSettings ( $ directory , $ settings ) ; foreach ( $ directorySpecification -> getFileSpecifications ( ) as $ fileSpecification ) $ this -> _processFileSpecification ( $ artifact , $ fileSpecification ) ; } } }
Processes the files and directories .
12,190
private function _processFileSpecification ( $ artifact , $ fileSpecification ) { if ( ! in_array ( basename ( $ fileSpecification -> getSource ( ) ) , $ this -> exclude ) ) $ this -> processFileSpecification ( $ artifact , $ fileSpecification ) ; }
Processes a file from a specification . Considers globally excluded files . Only exact file names are supported .
12,191
public static function get ( $ name , $ call = true ) { if ( ! isset ( self :: $ services [ $ name ] ) ) { throw new \ RuntimeException ( "The service [$name] don't register." ) ; } $ service = self :: $ services [ $ name ] ; if ( \ is_object ( $ service ) && $ service instanceof \ Closure && $ call ) { if ( ! isset ( self :: $ instances [ $ name ] ) ) { self :: $ instances [ $ name ] = $ service ( ) ; } return self :: $ instances [ $ name ] ; } return $ service ; }
get a app service by name if is a closure only run once .
12,192
public static function factory ( $ name ) { if ( ! isset ( self :: $ services [ $ name ] ) ) { throw new \ RuntimeException ( "The service [$name] don't register." ) ; } $ service = self :: $ services [ $ name ] ; if ( \ is_object ( $ service ) && method_exists ( $ service , '__invoke' ) ) { return $ service ( ) ; } return $ service ; }
create a app service by name it always return a new instance .
12,193
public function addExtraClasses ( $ classes ) { if ( ! is_array ( $ classes ) ) { $ classes = explode ( " " , $ classes ) ; } $ this -> extra_classes = array_merge ( $ this -> extra_classes , $ classes ) ; return $ this ; }
Add additional css classes
12,194
public function removeExtraClasses ( $ classes ) { if ( ! is_array ( $ classes ) ) { $ classes = explode ( " " , $ classes ) ; } foreach ( $ classes as $ class ) { if ( isset ( $ this -> extra_classes [ $ class ] ) ) { unset ( $ this -> extra_classes [ $ class ] ) ; } } return $ this ; }
Remove provided CSS classes
12,195
public function build ( $ action , array $ data , CliInput $ input , Mapping $ mapping ) { $ payloadMeta = $ this -> mapper -> getPayloadMeta ( $ data ) ; if ( $ action === 'request' ) { return new RequestApi ( $ this -> logger -> getRequestLogger ( $ payloadMeta -> getId ( ) ) , $ this -> component , $ mapping , dirname ( realpath ( $ _SERVER [ 'SCRIPT_FILENAME' ] ) ) , $ input -> getName ( ) , $ input -> getVersion ( ) , $ input -> getFrameworkVersion ( ) , $ input -> getVariables ( ) , $ input -> isDebug ( ) , $ this -> mapper -> getHttpRequest ( $ data ) , $ this -> mapper -> getServiceCall ( $ data ) , $ payloadMeta , $ this -> mapper -> getRequestAttributes ( $ data ) ) ; } elseif ( $ action === 'response' ) { return new ResponseApi ( $ this -> logger -> getRequestLogger ( $ payloadMeta -> getId ( ) ) , $ this -> component , $ mapping , dirname ( realpath ( $ _SERVER [ 'SCRIPT_FILENAME' ] ) ) , $ input -> getName ( ) , $ input -> getVersion ( ) , $ input -> getFrameworkVersion ( ) , $ input -> getVariables ( ) , $ input -> isDebug ( ) , $ this -> mapper -> getHttpRequest ( $ data ) , $ this -> mapper -> getHttpResponse ( $ data ) , $ this -> mapper -> getTransport ( $ data ) , $ this -> mapper -> getPayloadMeta ( $ data ) , $ this -> mapper -> getReturnValue ( $ data ) ) ; } }
Build a Request Api class instance
12,196
public function getAttribute ( $ key ) { if ( isset ( $ this -> mutations [ $ key ] ) ) { return $ this -> mutations [ $ key ] ; } if ( array_key_exists ( $ key , $ mutatables = static :: getMutatables ( ) ) ) { return $ this -> mutateExtensionAttribute ( $ key , $ mutatables [ $ key ] ) ; } return parent :: getAttribute ( $ key ) ; }
Get an attribute from the model with custom accessor .
12,197
protected function mutateExtensionAttribute ( $ key , $ type ) { $ value = $ this -> getAttributeFromArray ( $ key ) ; $ mutation = $ this -> { 'make' . studly_case ( $ type ) . 'TypeMutation' } ( $ value ) ; $ this -> mutations [ $ key ] = $ mutation ; return $ mutation ; }
Mutates and stores an attribute in array
12,198
public function setLogger ( \ sb \ Logger \ Base $ logger , $ logname = '' ) { $ this -> logger = $ logger ; $ this -> log_name = $ logname ? $ logname : get_called_class ( ) ; $ this -> log_name = preg_replace ( "~[^\w+]~" , "_" , $ this -> log_name ) ; }
Set the logger that logs the full log message stream when the destructor runs
12,199
public function log ( $ message , $ type = "MESSAGE" , $ text_attributes = [ ] ) { $ type = strtoupper ( $ type ) ; switch ( $ type ) { case 'RAW' : break ; case 'ERROR' : $ this -> number_of_errors ++ ; $ this -> onError ( $ message ) ; default : $ message = $ type . ': ' . $ message ; } $ this -> logToFile ( $ message ) ; if ( empty ( $ text_attributes ) ) { file_put_contents ( "php://stdout" , "\n" . $ message ) ; return $ message ; } if ( is_array ( $ text_attributes ) ) { if ( isset ( $ text_attributes [ 'bold' ] ) && $ text_attributes [ 'bold' ] ) { file_put_contents ( "php://stdout" , "\033[1m" ) ; } if ( isset ( $ text_attributes [ 'underline' ] ) && $ text_attributes [ 'underline' ] ) { file_put_contents ( "php://stdout" , "\033[4m" ) ; } if ( isset ( $ text_attributes [ 'fgcolor' ] ) && isset ( $ this -> fgcolors [ $ text_attributes [ 'fgcolor' ] ] ) ) { file_put_contents ( "php://stdout" , "\033[" . $ this -> fgcolors [ $ text_attributes [ 'fgcolor' ] ] . "m" ) ; } if ( isset ( $ text_attributes [ 'bgcolor' ] ) && isset ( $ this -> fgcolors [ $ text_attributes [ 'bgcolor' ] ] ) ) { file_put_contents ( "php://stdout" , "\033[" . $ this -> bgcolors [ $ bgcolor ] . "m" ) ; } if ( isset ( $ text_attributes [ 'underline' ] ) && $ text_attributes [ 'underline' ] ) { file_put_contents ( "php://stdout" , "\033[4m" ) ; } if ( isset ( $ text_attributes [ 'overwrite' ] ) && $ text_attributes [ 'overwrite' ] ) { file_put_contents ( "php://stdout" , "\033[2K\033[A" ) ; } } else if ( is_string ( $ text_attributes ) && isset ( $ this -> fgcolors [ $ text_attributes ] ) ) { file_put_contents ( "php://stdout" , "\033[" . $ this -> fgcolors [ $ text_attributes ] . "m" ) ; } file_put_contents ( "php://stdout" , "\n" . $ message ) ; if ( ! is_array ( $ text_attributes ) || ! isset ( $ text_attributes [ 'keep' ] ) || ! $ text_attributes [ 'keep' ] ) { file_put_contents ( "php://stdout" , "\033[0m" ) ; } return $ message ; }
Logs to std out