idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
9,700
public function setAttributes ( ) { $ attributes = func_get_args ( ) ; if ( count ( $ attributes ) ) { if ( count ( $ attributes ) == 1 && is_array ( $ attributes [ 0 ] ) ) { $ attributes = $ attributes [ 0 ] ; } $ this -> attributes = $ attributes ; } return $ this ; }
Set one or many attributes .
9,701
private static function buildHtml ( & $ html , $ tag_object , $ options , $ tab = 0 ) { self :: checkBuildOptions ( $ options ) ; $ tag_is_special = in_array ( $ tag_object -> getTag ( ) , self :: $ special_tags ) ; $ tag_is_ignored = in_array ( $ tag_object -> getTag ( ) , array_get ( $ options , 'ignore_tags' , [ ] )...
Build html from this object .
9,702
private static function buildHtmlAttribute ( $ attributes ) { $ html = '' ; foreach ( $ attributes as $ name => $ value ) { $ html .= ' ' . $ name . '="' . $ value . '"' ; $ class_list = explode ( ' ' , $ value ) ; foreach ( $ class_list as $ class_name ) { switch ( $ class_name ) { case 'class' : if ( function_exists ...
Build html attributes from array .
9,703
private static function buildArray ( & $ array , $ tag_object , $ options = [ ] ) { self :: checkBuildOptions ( $ options ) ; if ( in_array ( $ tag_object -> getTag ( ) , self :: $ special_tags ) ) { $ array [ ] = [ trim ( ( string ) $ tag_object ) ] ; } elseif ( ! isset ( $ options [ 'ignore_tags' ] ) || ! in_array ( ...
Build an array from this object .
9,704
public static function buildFromArray ( & $ html , $ array , $ tab = 0 ) { $ pad = '' ; if ( $ tab > 0 ) { $ pad = str_pad ( $ pad , $ tab * 2 , ' ' , STR_PAD_LEFT ) ; } if ( ! isset ( $ array [ 1 ] ) ) { $ html .= $ array [ 0 ] . "\n" ; return ; } if ( ! empty ( $ array [ 0 ] ) ) { $ html .= $ pad ; $ html .= '<' . $ ...
Build html from an array .
9,705
public function prepare ( $ options = [ ] ) { if ( request ( ) -> ajax ( ) ) { return $ this -> getArray ( $ options ) ; } return $ this -> getHtml ( $ options ) ; }
Automatically returns the object based on the http request .
9,706
public static function fixNamespaceDeclarations ( $ source ) { if ( ! function_exists ( 'token_get_all' ) || ! self :: $ useTokenizer ) { if ( preg_match ( '/namespace(.*?)\s*;/' , $ source ) ) { $ source = preg_replace ( '/namespace(.*?)\s*;/' , "namespace$1\n{" , $ source ) . "}\n" ; } return $ source ; } $ rawChunk ...
Adds brackets around each namespace if it s not already the case .
9,707
private static function resolveDependencies ( array $ tree , $ node , \ ArrayObject $ resolved = null , \ ArrayObject $ unresolved = null ) { if ( null === $ resolved ) { $ resolved = new \ ArrayObject ( ) ; } if ( null === $ unresolved ) { $ unresolved = new \ ArrayObject ( ) ; } $ nodeName = $ node -> getName ( ) ; $...
Dependencies resolution .
9,708
public function ls ( $ remote_dir ) { $ dir = "ssh2.sftp://" . $ this -> sftp . $ remote_dir ; $ handle = opendir ( $ dir ) ; $ files = Array ( ) ; while ( false !== ( $ file = readdir ( $ handle ) ) ) { if ( substr ( $ file , 0 , 1 ) != '.' ) { $ files [ ] = $ file ; } } closedir ( $ handle ) ; return $ files ; }
Lists the contents of a remote directory
9,709
public function renameRemoteFile ( $ from , $ to ) { if ( @ ssh2_sftp_rename ( $ this -> sftp , $ from , $ to ) ) { throw new \ Exception ( "Could not rename file from $from to $to" ) ; } return true ; }
Renames remote files
9,710
public function getFileStats ( $ path ) { $ stats = @ ssh2_sftp_stat ( $ this -> sftp , $ path ) ; if ( ! $ stats [ 'size' ] ) { throw new \ Exception ( "Could get file stat: " . $ path ) ; } return $ stats ; }
Gets remote file stats
9,711
public function ssh2SftpSymlink ( $ orig_path , $ symlink_path ) { $ result = @ ssh2_sftp_symlink ( $ this -> sftp , $ orig_path , $ symlink_path ) ; if ( ! $ result ) { throw new \ Exception ( "Could create symlink: " . $ path ) ; } return $ result ; }
Create a symlink on the remote system
9,712
public static function createCache ( $ id , $ location = null , $ storageClass , $ options = array ( ) ) { if ( $ location !== null ) { if ( substr ( $ location , 0 , 1 ) === '/' ) { if ( ( $ realLocation = realpath ( $ location ) ) === false ) { throw new ezcBaseFileNotFoundException ( $ location , 'cache location' , ...
Creates a new cache in the manager . This method is used to create a new cache inside the manager . Each cache has a unique ID to access it during the application runtime . Each location may only be used by 1 cache .
9,713
protected function addRedirectUrlField ( ) { $ previous = URL :: previous ( ) ; if ( ! $ previous || $ previous == URL :: current ( ) ) { return ; } if ( Str :: contains ( $ previous , url ( $ this -> getResource ( ) ) ) ) { $ this -> addHiddenField ( ( new Form \ Field \ Hidden ( static :: PREVIOUS_URL_KEY ) ) -> valu...
Add field for store redirect url after update or store .
9,714
protected function processPlugins ( $ plugins , $ dir ) { foreach ( $ plugins as $ plugin ) { $ this -> addPlugin ( $ plugin , $ dir ) ; } }
Processes plugin definitions
9,715
public function addPlugin ( $ name , $ dir ) { Debug :: enterScope ( $ name ) ; $ hasPlugin = $ hasZfile = false ; try { $ this -> plugins [ $ name ] = $ this -> getLocator ( ) -> locate ( $ name . '/Plugin.php' , $ dir , true ) ; $ this -> pluginPaths [ $ name ] = dirname ( $ this -> plugins [ $ name ] ) ; $ hasPlugin...
Add a plugin at the passed location
9,716
protected function callClosureAttributes ( array $ attributes ) { foreach ( $ attributes as & $ attribute ) { $ attribute = $ attribute instanceof Closure ? $ attribute ( $ attributes ) : $ attribute ; } return $ attributes ; }
Evaluate any Closure attributes on the attribute array .
9,717
public function remove ( $ key ) { $ keyGen = $ this -> generateKey ( $ key ) ; $ this -> cache -> remove ( $ keyGen ) ; @ unlink ( $ this -> getFilePath ( $ keyGen ) ) ; }
Removes tempnam file by its key
9,718
public function load ( $ key , \ DateTimeInterface $ updatedAt = null ) { $ keyGen = $ this -> generateKey ( $ key ) ; $ updateDate = $ this -> cache -> load ( $ keyGen ) ; if ( $ updateDate === null || $ updateDate != $ updatedAt ) { if ( $ updateDate ) { $ this -> remove ( $ key ) ; } return null ; } return $ this ->...
Loads tempnam file path
9,719
public function save ( $ key , $ data , \ DateTimeInterface $ updatedAt = null ) { $ keyGen = $ this -> generateKey ( $ key ) ; $ path = $ this -> putFile ( $ keyGen , $ data ) ; $ this -> cache -> save ( $ keyGen , $ updatedAt ) ; return $ path ; }
Saves tempnam file and returns its path
9,720
private function clean ( ) { foreach ( Finder :: find ( $ this -> namespace . '*' ) -> from ( $ this -> tempDir ) -> childFirst ( ) as $ entry ) { $ path = ( string ) $ entry ; if ( $ entry -> isDir ( ) ) { continue ; } $ updateDate = $ this -> cache -> load ( $ entry -> getFilename ( ) ) ; if ( $ updateDate === null )...
Cleans unused tempnam files
9,721
public function deliveryAddresses ( $ personId ) { $ deliveryAddresses = $ this -> execute ( self :: HTTP_GET , self :: DOMUSERP_API_PEDIDOVENDA . '/pessoas/' . $ personId . '/enderecosentrega' ) ; return $ deliveryAddresses ; }
Gets the delivery address of the person according to the id passed as parameter
9,722
public function orderDefaultValues ( $ personId ) { $ orderDefaultValues = $ this -> execute ( self :: HTTP_GET , self :: DOMUSERP_API_PEDIDOVENDA . '/pessoas/' . $ personId . '/valoresPadraoPedido' ) ; return $ orderDefaultValues ; }
Gets the order default values of a person according to the person id passed as parameter
9,723
public function addStyle ( $ name , $ properties ) { $ style = $ this -> createElement ( 'ss:Style' ) ; $ style -> setAttribute ( 'ss:ID' , $ name ) ; $ this -> styles -> appendChild ( $ style ) ; $ font = $ this -> createElement ( 'ss:Font' ) ; $ style -> appendChild ( $ font ) ; foreach ( $ properties as $ prop => $ ...
Creates a new style node and adds it to the styles section
9,724
public function addWorksheet ( $ title ) { $ worksheet = $ this -> workbook -> appendChild ( $ this -> createElement ( 'Worksheet' ) ) ; $ title = preg_replace ( "/[\\\|:|\/|\?|\*|\[|\]]/" , "" , $ title ) ; $ title = substr ( $ title , 0 , 31 ) ; $ worksheet -> setAttribute ( 'ss:Name' , $ title ) ; $ worksheet -> tab...
Adds a new worksheet to the workbook
9,725
public function setActiveWorksheet ( $ worksheet ) { if ( is_string ( $ worksheet ) ) { $ worksheet = $ this -> worksheets [ md5 ( $ worksheet ) ] ; } $ this -> active_worksheet = $ worksheet ; return $ worksheet ; }
Sets the active worksheet
9,726
public function setRow ( $ row_index , $ values_arr , $ type = null ) { $ cell = null ; foreach ( $ values_arr as $ col_index => $ val ) { $ cell = $ this -> setCell ( $ col_index + 1 , $ row_index , $ val , $ type ) ; } if ( $ cell ) { return $ cell -> parentNode ; } return false ; }
Sets an entire row of data
9,727
public function setCell ( $ col_index , $ row_index , $ val , $ type = null ) { $ result = $ this -> xpath -> query ( "//Row[@Index='" . $ row_index . "']/Cell[@Index='" . $ col_index . "']/Data" , $ this -> active_worksheet ) ; $ data = $ result -> item ( 0 ) ; $ type = $ type ? $ type : $ this -> getValueType ( $ val...
Sets a cell by 1 based column and row index
9,728
public function outputWithHeaders ( $ filename = 'worksheet' ) { $ filename = preg_replace ( '/[^aA-zZ0-9\_\-]/' , '' , $ filename ) ; header ( "Content-Type: application/msexcel; charset=" . $ this -> encoding ) ; header ( "Content-Disposition: inline; filename=\"" . $ filename . ".xlsx\"" ) ; echo $ this -> __toStrin...
Used to generate the xml with output headers
9,729
protected function getValueType ( $ val ) { $ type = 'String' ; if ( $ this -> auto_convert_types === true && is_numeric ( $ val ) ) { $ type = 'Number' ; } return $ type ; }
Determines value type
9,730
protected function alphaIndexToNumeric ( $ alpha_index ) { preg_match ( "~([A-Z]+)(\d)+~" , $ alpha_index , $ match ) ; $ letters = range ( 'A' , 'Z' ) ; $ letters = array_flip ( $ letters ) ; $ col_index = 0 ; $ strlen = strlen ( $ match [ 1 ] ) ; if ( $ strlen == 1 ) { $ col_index += ( $ letters [ $ match [ 1 ] ] + 1...
Converts Alpha column data to numeric indexes
9,731
public function getMessageType ( ) { $ messageType = static :: types ( ) [ $ this -> type ] ; if ( $ this -> type != static :: INCOMING ) { $ messageType = strtoupper ( $ messageType ) ; } return $ messageType ; }
Get message type
9,732
public function convert ( \ DOMElement $ parent , TraitDescriptor $ trait ) { $ child = new \ DOMElement ( 'trait' ) ; $ parent -> appendChild ( $ child ) ; $ namespace = $ trait -> getNamespace ( ) -> getFullyQualifiedStructuralElementName ( ) ; $ child -> setAttribute ( 'namespace' , ltrim ( $ namespace , '\\' ) ) ; ...
Export the given reflected Trait definition to the provided parent element .
9,733
public static function fromArrayAndSettings ( $ cfg , $ settings , $ artifact = null ) { $ chunkSpecification = new static ( $ cfg , $ settings -> getDirectory ( ) ) ; $ chunkSpecification -> set ( "source" , null ) ; $ chunkSpecification -> set ( "target" , fphp \ Helper \ Path :: join ( $ settings -> getOptional ( "t...
Creates a chunk specification from a plain settings array . The settings context is taken into consideration to generate paths relative to the settings .
9,734
public function getSpriteWebvttForEpisode ( $ episode , $ player_type = "jwplayer" ) { $ this -> calculateInterval ( $ episode ) ; switch ( $ player_type ) { case 'jwplayer' : return $ this -> getSpriteWebvttForJwPlayer ( $ episode ) ; break ; default : return $ this -> getSpriteWebvttForJwPlayer ( $ episode ) ; break ...
returns webvtt formated string for webplayers to display thumbnails
9,735
private function calculateInterval ( $ episode ) { $ max_image = floor ( 65500 / $ this -> sprite_height ) ; $ calculated_interval = ceil ( $ episode -> getDuration ( ) / $ max_image ) ; if ( $ calculated_interval > $ this -> sprite_interval ) { $ this -> sprite_interval = $ calculated_interval ; } }
calculates the interval time for the length of an episode and considers jpeg dimension limit of 65500 px .
9,736
protected function _auto ( $ str ) { $ self = $ this ; return preg_replace_callback ( '/`.*?<(.+?)>.*?`|<(.+?)>/' , function ( $ expr ) use ( $ self ) { if ( empty ( $ expr [ 1 ] ) && parse_url ( $ expr [ 2 ] , PHP_URL_SCHEME ) ) { $ expr [ 2 ] = $ self -> esc ( $ expr [ 2 ] ) ; return '<a href="' . $ expr [ 2 ] . '">'...
Auto - convert links
9,737
protected function _code ( $ str ) { $ self = $ this ; return preg_replace_callback ( '/`` (.+?) ``|(?<!\\\\)`(.+?)(?!\\\\)`/' , function ( $ expr ) use ( $ self ) { return '<code>' . $ self -> esc ( empty ( $ expr [ 1 ] ) ? $ expr [ 2 ] : $ expr [ 1 ] ) . '</code>' ; } , $ str ) ; }
Process code span
9,738
function esc ( $ str ) { if ( ! $ this -> special ) $ this -> special = array ( '...' => '&hellip;' , '(tm)' => '&trade;' , '(r)' => '&reg;' , '(c)' => '&copy;' ) ; foreach ( $ this -> special as $ key => $ val ) $ str = preg_replace ( '/' . preg_quote ( $ key , '/' ) . '/i' , $ val , $ str ) ; return htmlspecialchars ...
Convert characters to HTML entities
9,739
protected function getStatusCodeFromApiProblem ( ApiProblem $ problem ) { $ problemData = $ problem -> toArray ( ) ; $ status = array_key_exists ( 'status' , $ problemData ) ? $ problemData [ 'status' ] : 0 ; if ( $ status < 100 || $ status >= 600 ) { return 500 ; } return $ status ; }
Retrieve the HTTP status from an ApiProblem object
9,740
public static function getSizesFor ( string $ size , string $ type , int $ pageUid ) : array { $ settings = ColumnLayoutUtility :: getColumnLayoutSettings ( $ pageUid ) ; if ( ! array_key_exists ( $ size . '.' , $ settings [ 'sizes.' ] ) ) { throw new Exception ( sprintf ( 'The given size "%s" is not defined in the gri...
Calculates the column sizes for the given size and the given size type
9,741
public static function getColumnLayoutSettings ( int $ page ) : array { $ pageTSConfig = BackendUtility :: getPagesTSconfig ( $ page ) ; if ( ! array_key_exists ( 'column_layout.' , $ pageTSConfig [ 'mod.' ] ) ) { throw new Exception ( sprintf ( 'No column layout found for page "%d". Please define the column_layout set...
Returns the column layout configuration from page TSConfig .
9,742
public static function hydrateLayoutConfigFlexFormData ( $ flexFormData ) : array { $ dataStructure = $ flexFormData ; if ( is_string ( $ flexFormData ) ) { $ dataStructure = GeneralUtility :: xml2array ( $ flexFormData ) ; } return array_map ( function ( $ sheet ) { return array_map ( function ( $ field ) { return $ f...
Simplify a FlexForm DataStructure array . Removes all unnecessary sheet field or value identifiers .
9,743
public function getCustomerGroup ( ConnectionInterface $ con = null ) { if ( $ this -> aCustomerGroup === null && ( $ this -> id !== null ) ) { $ this -> aCustomerGroup = ChildCustomerGroupQuery :: create ( ) -> findPk ( $ this -> id , $ con ) ; } return $ this -> aCustomerGroup ; }
Get the associated ChildCustomerGroup object
9,744
public function getHostWithPort ( ) { if ( $ this -> hasPort ( ) && ( ! $ this -> hasDefaultPort ( ) || ! $ this -> isPortDefault ( ) ) ) { return $ this -> getHost ( ) . ':' . $ this -> getPort ( ) ; } else { return $ this -> getHost ( ) ; } }
Host including port unless it is the default port for the scheme .
9,745
public function getDefaultPort ( ) { if ( ! $ this -> hasDefaultPort ( ) ) throw new UrlException ( sprintf ( "No default port for URL '%s'" , $ this -> _inputString ) ) ; $ scheme = $ this -> getScheme ( ) ; if ( $ scheme == 'http' ) return 80 ; elseif ( $ scheme == 'https' ) return 443 ; else throw new UrlException (...
The default TCP port for the scheme of the URL
9,746
public function getHostRelativeUrl ( ) { $ url = $ this -> getPath ( ) ; if ( $ this -> hasQueryString ( ) ) $ url .= '?' . $ this -> getQueryString ( ) ; if ( $ this -> hasFragmentString ( ) ) $ url .= '#' . $ this -> getFragmentString ( ) ; return $ url ; }
The URL components after the host .
9,747
public function getUrlForPath ( $ path ) { $ fragments = parse_url ( $ path ) ; if ( ! isset ( $ fragments [ 'path' ] ) ) throw new UrlException ( "URL is not a valid path: '$path'" ) ; $ newUrl = clone $ this ; $ newUrl -> _fragments [ 'path' ] = $ fragments [ 'path' ] ; foreach ( array ( 'query' , 'fragment' ) as $ c...
Builds a URL with a different path component
9,748
public function getUrlForHost ( $ host ) { $ newUrl = clone $ this ; $ newUrl -> _fragments [ 'host' ] = $ host ; $ newUrl -> _inputString = $ newUrl -> __toString ( ) ; return $ newUrl ; }
Builds a URL with a different host
9,749
public function getUrlForScheme ( $ scheme ) { $ newUrl = clone $ this ; $ wasDefaultPort = ( $ newUrl -> hasScheme ( ) && $ newUrl -> isPortDefault ( ) ) ; $ newUrl -> _fragments [ 'scheme' ] = $ scheme ; if ( $ wasDefaultPort ) { $ newUrl -> _fragments [ 'port' ] = $ newUrl -> getDefaultPort ( ) ; } $ newUrl -> _inpu...
Builds a URL with a different scheme
9,750
public function getUrlForRelativePath ( $ path ) { return $ this -> getUrlForPath ( $ this -> _joinPathComponents ( $ this -> getPath ( ) , ltrim ( $ path , '/' ) ) ) ; }
Builds a URL with a path component that is relative to the current one
9,751
public function addAuthor ( $ author ) { if ( ! is_array ( $ author ) ) { $ author = [ 'name' => $ author ] ; } $ this -> authors -> add ( ( object ) $ author ) ; }
Add an Author to the feed
9,752
public function render ( ) { $ this -> prepare ( ) ; $ view = $ this -> twig -> render ( sprintf ( '%s.twig.html' , $ this -> format ) , [ 'feed' => $ this ] ) ; return Response :: create ( $ view , 200 , [ 'Content-Type' => "{$this->getContentType()}; charset={$this->charset}" , ] ) ; }
Prepare the feed and if it s valid renders it
9,753
public function setCell ( $ cell , $ value , $ type = "auto" ) { if ( $ type == "auto" ) { $ type = \ gettype ( $ value ) ; } if ( \ is_array ( $ cell ) ) { $ parts [ "row" ] = $ cell [ 0 ] ; $ parts [ "col" ] = $ cell [ 1 ] ; } else { $ parts = $ this -> refToArray ( $ cell ) ; } if ( ! \ is_array ( $ parts ) ) { \ tr...
Set the value of an individual cell
9,754
public function setRow ( $ row , $ values ) { if ( ! \ is_array ( $ values ) ) { \ trigger_error ( "Values must be an array." , E_USER_ERROR ) ; return false ; } if ( intval ( $ row ) < 1 ) { \ trigger_error ( "Row number must be an integer greater than 1." , E_USER_ERROR ) ; return false ; } $ i = 0 ; foreach ( $ valu...
Set the values for a row
9,755
public function outputWithHeaders ( $ filename = 'output.xls' ) { \ header ( "Expires: " . date ( "r" , 0 ) ) ; \ header ( "Last-Modified: " . gmdate ( "r" ) . " GMT" ) ; \ header ( "Content-Type: application/x-msexcel" ) ; \ header ( "Content-Disposition: attachment; filename=" . $ filename ) ; echo $ this -> __toStri...
Stream this file over HTTP
9,756
protected function _sort ( ) { if ( ! isset ( $ this -> _sorts ) || count ( $ this -> _sorts ) === 0 ) { return ; } $ columns = $ this -> _dataGrid -> getActiveColumnsOrdered ( ) ; $ sorts = $ this -> _sorts ; $ sortPosition = $ this -> _sortPositions ; usort ( $ this -> _output , function ( $ a , $ b ) use ( $ columns...
Performs an array_multisort based on the sorts defined
9,757
protected function _truncate ( ) { if ( ! $ this -> getLimit ( ) -> isNull ( ) ) { if ( is_null ( $ this -> getLimit ( ) -> getCount ( ) ) ) { $ this -> _output = array_splice ( $ this -> _output , $ this -> getLimit ( ) -> getStart ( ) ) ; } else { $ this -> _output = array_splice ( $ this -> _output , $ this -> getLi...
Simply splice the array
9,758
private static function mandatory ( $ feature ) { if ( $ feature -> getParent ( ) && $ feature -> getMandatory ( ) ) return Logic :: equiv ( Logic :: is ( $ feature ) , Logic :: is ( $ feature -> getParent ( ) ) ) ; }
Semantics for a mandatory feature . A mandatory feature is selected iff its parent is selected .
9,759
private static function optional ( $ feature ) { if ( $ feature -> getParent ( ) ) return Logic :: implies ( Logic :: is ( $ feature ) , Logic :: is ( $ feature -> getParent ( ) ) ) ; }
Semantics for an optional feature . If an optional feature is selected its parent is selected .
9,760
private static function alternative ( $ feature ) { if ( $ feature -> getAlternative ( ) ) { $ children = array ( ) ; foreach ( $ feature -> getChildren ( ) as $ child ) $ children [ ] = Logic :: is ( $ child ) ; $ alternativeConstraints = array ( ) ; for ( $ i = 0 ; $ i < count ( $ children ) ; $ i ++ ) for ( $ j = 0 ...
Semantics for a feature that provides an alternative choice . Exactly one child of such a feature is selected .
9,761
private static function _or ( $ feature ) { if ( $ feature -> getOr ( ) ) { $ children = array ( ) ; foreach ( $ feature -> getChildren ( ) as $ child ) $ children [ ] = Logic :: is ( $ child ) ; return Logic :: equiv ( Logic :: is ( $ feature ) , call_user_func_array ( "\FeaturePhp\Helper\Logic::_or" , $ children ) ) ...
Semantics for a feature that provides a choice using an inclusive or . At least one child of such a feature is selected .
9,762
private function crossTreeConstraint ( $ rule ) { $ op = $ rule -> getName ( ) ; $ num = $ rule -> count ( ) ; if ( $ op === "eq" && $ num === 2 ) return Logic :: equiv ( $ this -> crossTreeConstraint ( $ rule -> children ( ) [ 0 ] ) , $ this -> crossTreeConstraint ( $ rule -> children ( ) [ 1 ] ) ) ; if ( $ op === "im...
Transforms a cross - tree constraint from an XML rule to a formula .
9,763
public function dispatch ( $ name , $ event ) { if ( ! $ this -> event_dispatcher ) { return null ; } if ( ! $ this -> event_dispatcher instanceof Dispatcher ) { throw new \ Exception ( 'Expected the event dispatcher to be an instance of phpDocumentor\Event\Dispatcher' ) ; } $ this -> event_dispatcher -> dispatch ( $ n...
Dispatches an event to the Event Dispatcher .
9,764
public function logParserError ( $ type , $ code , $ line , $ variables = array ( ) ) { $ message = $ this -> __ ( $ code , $ variables ) ; $ this -> log ( $ message , LogLevel :: ERROR ) ; $ this -> dispatch ( 'parser.log' , LogEvent :: createInstance ( $ this ) -> setMessage ( $ message ) -> setType ( $ type ) -> set...
Dispatches a parser error to be logged .
9,765
public function __ ( $ message , $ variables = array ( ) ) { if ( ! $ this -> translate ) { return vsprintf ( $ message , $ variables ) ; } $ translator = $ this -> translate ; return vsprintf ( $ translator -> translate ( $ message ) , $ variables ) ; }
Translates the ID or message in the given language .
9,766
public function from ( $ type ) { switch ( $ type ) { case 'ini' : $ this -> data = Ini :: decode ( $ this -> string ) ; break ; case 'json' : $ this -> data = Json :: decode ( $ this -> string ) ; break ; case 'php' : $ this -> data = Php :: decode ( $ this -> string ) ; break ; case 'xml' : $ this -> data = Xml :: de...
Specifies the structure type which the content will be parsed from
9,767
public function to ( $ type ) { switch ( $ type ) { case 'ini' : $ this -> string = Ini :: encode ( $ this -> data ) ; break ; case 'json' : $ this -> string = Json :: encode ( $ this -> data , $ this -> prettyOutput ) ; break ; case 'php' : $ this -> string = Php :: encode ( $ this -> data ) ; break ; case 'xml' : $ t...
Specifies the format you want to encode the data to
9,768
public function apply ( Builder $ builder ) { $ this -> builder = $ builder ; $ this -> builder -> select ( "{$this->getTableName()}.*" ) ; foreach ( $ this -> filters ( ) as $ name => $ value ) { $ this -> callFilterMethod ( $ name , $ value ) ; } return $ this -> builder ; }
Applies all available filters .
9,769
protected function resolve ( $ column , $ key , $ last , callable $ callback ) { if ( ! strpos ( $ column , '.' ) ) { return $ callback ( "{$last}.{$column}" , $ key ) ; } $ scope = strstr ( $ column , '.' , true ) ; $ singular = str_singular ( $ scope ) ; $ next = substr ( strstr ( $ column , '.' ) , 1 ) ; if ( ! in_a...
Recursively build up the query .
9,770
public function _render ( $ textOnly ) { $ featureNum = count ( $ this -> product -> getConfiguration ( ) -> getSelectedFeatures ( ) ) ; $ fileNum = count ( $ this -> files ) ; $ str = "" ; $ maxLen = fphp \ Helper \ _String :: getMaxLength ( $ this -> files , "getTarget" ) ; if ( $ textOnly ) $ str .= "\nProduct Analy...
Returns the product analysis .
9,771
public function table ( ) { if ( ! $ this -> _properties [ 'table_name' ] ) { $ class = explode ( '\\' , get_called_class ( ) ) ; $ this -> _properties [ 'table_name' ] = Instance :: snakecase ( lcfirst ( end ( $ class ) ) ) ; } return $ this -> _properties [ 'table_name' ] ; }
Return table name
9,772
public function field ( $ name ) { return isset ( $ this -> _properties [ 'fields' ] [ $ name ] ) ? $ this -> _properties [ 'fields' ] [ $ name ] : null ; }
return field alias
9,773
public function get ( $ var ) { return isset ( $ this -> _schema [ 'values' ] [ $ var ] ) ? $ this -> _schema [ 'values' ] [ $ var ] : ( isset ( $ this -> _schema [ 'others' ] [ $ var ] ) ? $ this -> _schema [ 'others' ] [ $ var ] : null ) ; }
Get fields value
9,774
public function findByPK ( ) { $ pk = func_get_args ( ) ; if ( ! $ this -> _properties [ 'primary_key' ] || ! $ pk ) throw new Exception ( sprintf ( self :: E_PrimaryKey , get_called_class ( ) ) , 1 ) ; ! is_array ( reset ( $ pk ) ) || $ pk = array_shift ( $ pk ) ; $ criteria = $ values = array ( ) ; foreach ( $ this -...
Find by PK
9,775
public function pkValue ( ) { if ( $ args = func_get_args ( ) ) { ! is_array ( $ args [ 0 ] ) || $ args = array_shift ( $ args ) ; $ args = array_values ( $ args ) ; foreach ( $ args as $ key => $ arg ) $ this -> { $ this -> _properties [ 'primary_key' ] [ $ key ] } = $ arg ; return $ this ; } $ pk = array_intersect_ke...
Get PK Value
9,776
public function generatePK ( ) { $ format = $ this -> pkFormat ; $ pk = $ this -> _properties [ 'primary_key' ] ; if ( isset ( $ pk [ 1 ] ) ) throw new Exception ( sprintf ( self :: E_Composit , get_called_class ( ) , __FUNCTION__ ) , 1 ) ; $ pk = array_shift ( $ pk ) ; if ( ! $ pk ) throw new Exception ( sprintf ( sel...
Generate PK only if pk count = 1
9,777
public function unique ( $ criteria = null , array $ values = array ( ) ) { if ( ! $ this -> _properties [ 'primary_key' ] || ( ! $ values && ! $ criteria ) ) throw new Exception ( sprintf ( self :: E_PrimaryKey , get_called_class ( ) ) , 1 ) ; $ that = clone $ this ; $ values ? $ that -> find ( $ criteria , $ values )...
Check not existance
9,778
public function next ( ) { if ( ! $ this -> hasError ( ) ) { $ row = $ this -> _stmt -> fetch ( $ this -> _schema [ 'fetch' ] ) ; $ this -> assign ( $ row ? : array_fill_keys ( array_keys ( $ this -> _properties [ 'fields' ] ) , null ) ) ; } return $ this ; }
get next row and assign row to schema values
9,779
public function read ( $ limit = 0 ) { $ this -> limit ( $ limit ) ; $ query = $ this -> buildSelect ( ) ; $ this -> run ( $ query [ 'query' ] , $ query [ 'param' ] ) ; return $ this -> next ( ) ; }
perform select query
9,780
public function insert ( array $ data = array ( ) , $ update = false ) { $ this -> viewCheck ( __FUNCTION__ ) ; $ data = array_merge ( $ this -> _schema [ 'init' ] , array_filter ( $ this -> _schema [ 'values' ] , array ( $ this , 'filterRule' ) ) , array_filter ( $ this -> _schema [ 'others' ] , array ( $ this , 'filt...
Insert on duplicate key update
9,781
public function update ( array $ data = array ( ) , array $ criteria = array ( ) ) { $ this -> viewCheck ( __FUNCTION__ ) ; $ data = array_merge ( array_filter ( $ this -> _schema [ 'others' ] , array ( $ this , 'filterRule' ) ) , $ data ) ; $ params = array ( ) ; $ values = array_filter ( $ this -> _schema [ 'values' ...
Update only when there is primary key
9,782
public function delete ( array $ criteria = [ ] ) { $ this -> viewCheck ( __FUNCTION__ ) ; $ query = $ this -> buildDelete ( $ criteria ) ; $ old = clone $ this ; if ( ! $ this -> beforeDelete ( $ criteria ) ) return false ; if ( $ result = $ this -> run ( $ query , $ criteria ) ) $ this -> next ( ) ; if ( ! $ this -> ...
delete only when there is primary key
9,783
protected function performValidate ( $ key , & $ value ) { if ( ! $ filter = $ this -> _schema [ 'filter' ] [ $ key ] ) return true ; $ validation = Validation :: instance ( ) ; $ moe = Base :: instance ( ) ; $ field = $ this -> _properties [ 'fields' ] [ $ key ] ; foreach ( $ filter as $ func => $ param ) { if ( is_nu...
Perform validation We can use method in Base class or any method with full name call but you need to define a message to override default message Be aware when use a method
9,784
static function grabFunctionParameters ( $ class , $ function , array $ paramValues ) { $ declaredParams = ( new \ ReflectionMethod ( $ class , $ function ) ) -> getParameters ( ) ; $ paramNames = array_map ( function ( \ ReflectionParameter $ v ) { return $ v -> getName ( ) ; } , $ declaredParams ) ; $ paramDefaults =...
Return array keyed by parameter name of values passed into a class static function
9,785
public function onKernelRequest ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; foreach ( $ this -> firewalls as $ firewall ) { if ( true === $ firewall -> check ( $ request ) ) { return ; } } }
Respond to a REQUEST KernelEvent by validating the request against the registered firewalls .
9,786
public function getRelativeFileTarget ( $ aspectKernelTarget ) { return fphp \ Helper \ Path :: join ( fphp \ Helper \ Path :: rootPath ( dirname ( $ aspectKernelTarget ) ) , $ this -> fileSpecification -> getTarget ( ) ) ; }
Returns the path of the aspect s target file relative to the aspect kernel s target file .
9,787
public function getClassName ( ) { $ fileSource = $ this -> fileSpecification -> getSource ( ) ; return ( new fphp \ Helper \ PhpParser ( ) ) -> parseFile ( $ fileSource ) -> getExactlyOneClass ( $ fileSource ) -> name ; }
Returns the aspect s class name . For this the aspect s file has to be parsed .
9,788
private function register_ajax_script ( ) { return $ this -> register_script_common ( function ( ) { return [ 'endpoint' => $ this -> apply_filters ( 'admin_ajax' , admin_url ( 'admin-ajax.php' ) ) , 'nonce_key' => $ this -> get_nonce_key ( ) , 'nonce_value' => $ this -> create_nonce ( ) , 'is_admin_ajax' => true , ] ;...
register script for admin - ajax . php
9,789
public static function getGlobalValue ( $ name ) { return array_key_exists ( $ name , self :: $ globalValues ) ? self :: $ globalValues [ $ name ] : null ; }
Get global substitution value
9,790
protected function invoke ( $ method_name , $ request_method , array $ arguments = [ ] ) { $ method_name = strtolower ( $ request_method ) . '_' . $ this -> str -> to_snake_case ( $ method_name ) ; if ( ! is_callable ( [ $ this , $ method_name ] ) ) { return false ; } $ reflection = new \ ReflectionMethod ( $ this , $ ...
Search method and execute if exists .
9,791
public function convert_to_array ( $ raw_data ) { $ xml = new \ SimpleXMLElement ( $ raw_data ) ; $ xml -> registerXPathNamespace ( self :: XML_NAMESPACE , self :: XML_NAMESPACE_URL ) ; $ data = $ xml -> xpath ( self :: XPATH_CURRENCY ) ; $ currencies = array ( ) ; foreach ( $ data as $ currency ) { $ currencies [ ( st...
Convert raw currency data to array of currencies
9,792
public function indexLocale ( string $ projectKey , string $ localeId , array $ params = [ ] ) { if ( isset ( $ params [ 'tags' ] ) ) { $ params [ 'q' ] = 'tags:' . $ params [ 'tags' ] ; unset ( $ params [ 'tags' ] ) ; } $ response = $ this -> httpGet ( sprintf ( '/api/v2/projects/%s/locales/%s/translations' , $ projec...
Index a locale .
9,793
public function create ( string $ projectKey , string $ localeId , string $ keyId , string $ content , array $ params = [ ] ) { $ params [ 'locale_id' ] = $ localeId ; $ params [ 'key_id' ] = $ keyId ; $ params [ 'content' ] = $ content ; $ response = $ this -> httpPost ( sprintf ( '/api/v2/projects/%s/translations' , ...
Create a translation .
9,794
public function update ( string $ projectKey , string $ translationId , string $ content , array $ params = [ ] ) { $ params [ 'content' ] = $ content ; $ response = $ this -> httpPatch ( sprintf ( '/api/v2/projects/%s/translations/%s' , $ projectKey , $ translationId ) , $ params ) ; if ( ! $ this -> hydrator ) { retu...
Update a translation .
9,795
public function indexKey ( string $ projectKey , string $ keyId , array $ params = [ ] ) { if ( isset ( $ params [ 'tags' ] ) ) { $ params [ 'q' ] = 'tags:' . $ params [ 'tags' ] ; unset ( $ params [ 'tags' ] ) ; } $ response = $ this -> httpGet ( sprintf ( '/api/v2/projects/%s/keys/%s/translations' , $ projectKey , $ ...
List translations for a specific key .
9,796
protected function transformTranslation ( LocaleAwareInterface $ translation , $ fields , & $ values ) { foreach ( $ fields as $ field ) { $ values [ $ translation -> getLocale ( ) ] [ $ field ] = $ this -> propertyAccessor -> getValue ( $ translation , $ field ) ; } }
Transforms single translation
9,797
private function isOAuth2 ( RequestInterface $ request , array $ options ) { if ( ! isset ( $ options [ 'auth' ] ) || $ options [ 'auth' ] !== 'oauth2' ) { return false ; } if ( $ this -> provider -> getBaseAccessTokenUrl ( [ ] ) === $ request -> getUri ( ) ) { return false ; } return true ; }
Check if a request is configured to use OAuth2 .
9,798
private function authenticateRequest ( RequestInterface $ request , AccessToken $ token ) { foreach ( $ this -> provider -> getHeaders ( $ token -> getToken ( ) ) as $ name => $ value ) { $ request = $ request -> withHeader ( $ name , $ value ) ; } return $ request ; }
Add authentication to an HTTP request .
9,799
private function getAccessToken ( AccessToken $ invalid = null ) { if ( ! isset ( $ this -> accessToken ) || $ this -> accessToken -> hasExpired ( ) || ( $ invalid && $ this -> accessToken === $ invalid ) ) { $ this -> accessToken = $ this -> acquireAccessToken ( ) ; if ( is_callable ( $ this -> tokenSave ) ) { call_us...
Get the current access token .