idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
16,100
|
public function getErrorElement ( ) { if ( empty ( self :: $ session_vars [ "error_element" ] ) ) { return "" ; } $ felm = self :: $ session_vars [ "error_element" ] ; unset ( self :: $ session_vars [ "error_element" ] ) ; return $ felm ; }
|
Returns the field to be highlighted .
|
16,101
|
public function setError ( $ message , $ details = "" , $ code = "" ) { if ( empty ( $ message ) ) { return ; } self :: $ session_vars [ "errors" ] [ $ message ] = [ "message" => $ message , "details" => $ details , "code" => $ code ] ; }
|
Stores the error to be reported .
|
16,102
|
public function setWarning ( $ message , $ details = "" ) { if ( empty ( $ message ) ) { return ; } self :: $ session_vars [ "warnings" ] [ $ message ] = [ "message" => $ message , "details" => $ details ] ; }
|
Stores the warning to be reported .
|
16,103
|
public function setProgWarning ( $ message , $ details = "" ) { if ( empty ( $ message ) || ! $ this -> progWarningsActive ( ) ) { return ; } self :: $ session_vars [ "prog_warnings" ] [ $ message ] = [ "message" => $ message , "details" => $ details ] ; }
|
Stores the programming warning to be reported .
|
16,104
|
public function setDebugMessage ( $ message , $ details = "" ) { if ( empty ( $ message ) ) { return ; } self :: $ session_vars [ "debug" ] [ $ message ] = [ "message" => $ message , "details" => $ details ] ; }
|
Stores the debugging message to be reported .
|
16,105
|
public function setInfo ( $ message , $ details = "" , $ auto_hide = false ) { if ( empty ( $ message ) ) { return ; } self :: $ session_vars [ "infos" ] [ $ message ] = [ "message" => $ message , "details" => $ details , "auto_hide" => $ auto_hide ] ; }
|
Stores the information message to be reported .
|
16,106
|
public function clearAll ( ) { $ this -> clearErrors ( ) ; $ this -> clearWarnings ( ) ; $ this -> clearProgWarnings ( ) ; $ this -> clearDebugMessages ( ) ; $ this -> clearInfos ( ) ; unset ( self :: $ session_vars [ "focus_element" ] ) ; unset ( self :: $ session_vars [ "error_element" ] ) ; unset ( self :: $ session_vars [ "active_tab" ] ) ; }
|
Clears all stored messages and active elements .
|
16,107
|
public function addMessagesToResponse ( & $ response ) { if ( $ this -> infosExist ( ) ) { $ response [ "INFO_MESSAGES" ] = $ this -> getInfos ( ) ; } if ( $ this -> warningsExist ( ) ) { $ response [ "WARNING_MESSAGES" ] = $ this -> getWarnings ( ) ; } if ( $ this -> errorsExist ( ) ) { $ response [ "ERROR_MESSAGES" ] = $ this -> getErrors ( ) ; } if ( $ this -> progWarningsExist ( ) ) { $ response [ "PROG_WARNINGS" ] = $ this -> getProgWarnings ( ) ; } if ( $ this -> debugMessageExists ( ) ) { $ response [ "DEBUG_MESSAGES" ] = $ this -> getDebugMessages ( ) ; } $ response [ "AUTO_HIDE_TIME" ] = $ this -> getAutoHideTime ( ) ; $ response [ "FOCUS_ELEMENT" ] = $ this -> getFocusElement ( ) ; $ response [ "ACTIVE_TAB" ] = $ this -> getActiveTab ( ) ; $ response [ "ERROR_ELEMENT" ] = $ this -> getErrorElement ( ) ; }
|
Add all stored existing messages to the response .
|
16,108
|
public function addNode ( \ DOMNode $ node ) { if ( $ node instanceof \ DOMDocument ) { $ node = $ node -> documentElement ; } if ( null !== $ this -> document && $ this -> document !== $ node -> ownerDocument ) { throw new \ InvalidArgumentException ( 'Attaching DOM nodes from multiple documents in the same crawler is forbidden.' ) ; } if ( null === $ this -> document ) { $ this -> document = $ node -> ownerDocument ; } if ( in_array ( $ node , $ this -> nodes , true ) ) { return ; } $ this -> nodes [ ] = $ node ; }
|
Adds a \ DOMNode instance to the list of nodes .
|
16,109
|
public function parents ( ) { if ( ! $ this -> nodes ) { throw new \ InvalidArgumentException ( 'The current node list is empty.' ) ; } $ node = $ this -> getNode ( 0 ) ; $ nodes = array ( ) ; while ( $ node = $ node -> parentNode ) { if ( XML_ELEMENT_NODE === $ node -> nodeType ) { $ nodes [ ] = $ node ; } } return $ this -> createSubCrawler ( $ nodes ) ; }
|
Returns the parents nodes of the current selection .
|
16,110
|
public function evaluate ( $ xpath ) { if ( null === $ this -> document ) { throw new \ LogicException ( 'Cannot evaluate the expression on an uninitialized crawler.' ) ; } $ data = array ( ) ; $ domxpath = $ this -> createDOMXPath ( $ this -> document , $ this -> findNamespacePrefixes ( $ xpath ) ) ; foreach ( $ this -> nodes as $ node ) { $ data [ ] = $ domxpath -> evaluate ( $ xpath , $ node ) ; } if ( isset ( $ data [ 0 ] ) && $ data [ 0 ] instanceof \ DOMNodeList ) { return $ this -> createSubCrawler ( $ data ) ; } return $ data ; }
|
Evaluates an XPath expression .
|
16,111
|
public function selectLink ( $ value ) { $ xpath = sprintf ( 'descendant-or-self::a[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) ' , static :: xpathLiteral ( ' ' . $ value . ' ' ) ) . sprintf ( 'or ./img[contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)]]' , static :: xpathLiteral ( ' ' . $ value . ' ' ) ) ; return $ this -> filterRelativeXPath ( $ xpath ) ; }
|
Selects links by name or alt value for clickable images .
|
16,112
|
public function selectButton ( $ value ) { $ translate = 'translate(@type, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz")' ; $ xpath = sprintf ( 'descendant-or-self::input[((contains(%s, "submit") or contains(%1$s, "button")) and contains(concat(\' \', normalize-space(string(@value)), \' \'), %s)) ' , $ translate , static :: xpathLiteral ( ' ' . $ value . ' ' ) ) . sprintf ( 'or (contains(%s, "image") and contains(concat(\' \', normalize-space(string(@alt)), \' \'), %s)) or @id=%s or @name=%s] ' , $ translate , static :: xpathLiteral ( ' ' . $ value . ' ' ) , static :: xpathLiteral ( $ value ) , static :: xpathLiteral ( $ value ) ) . sprintf ( '| descendant-or-self::button[contains(concat(\' \', normalize-space(string(.)), \' \'), %s) or @id=%s or @name=%s]' , static :: xpathLiteral ( ' ' . $ value . ' ' ) , static :: xpathLiteral ( $ value ) , static :: xpathLiteral ( $ value ) ) ; return $ this -> filterRelativeXPath ( $ xpath ) ; }
|
Selects a button by name or alt value for images .
|
16,113
|
public function link ( $ method = 'get' ) { if ( ! $ this -> nodes ) { throw new \ InvalidArgumentException ( 'The current node list is empty.' ) ; } $ node = $ this -> getNode ( 0 ) ; if ( ! $ node instanceof \ DOMElement ) { throw new \ InvalidArgumentException ( sprintf ( 'The selected node should be instance of DOMElement, got "%s".' , get_class ( $ node ) ) ) ; } return new Link ( $ node , $ this -> baseHref , $ method ) ; }
|
Returns a Link object for the first node in the list .
|
16,114
|
public function links ( ) { $ links = array ( ) ; foreach ( $ this -> nodes as $ node ) { if ( ! $ node instanceof \ DOMElement ) { throw new \ InvalidArgumentException ( sprintf ( 'The current node list should contain only DOMElement instances, "%s" found.' , get_class ( $ node ) ) ) ; } $ links [ ] = new Link ( $ node , $ this -> baseHref , 'get' ) ; } return $ links ; }
|
Returns an array of Link objects for the nodes in the list .
|
16,115
|
public function setVisit ( \ BlackForest \ PiwikBundle \ Entity \ PiwikVisit $ visit = null ) { $ this -> visit = $ visit ; return $ this ; }
|
Set visit .
|
16,116
|
public function setAction ( \ BlackForest \ PiwikBundle \ Entity \ PiwikAction $ action = null ) { $ this -> action = $ action ; return $ this ; }
|
Set action .
|
16,117
|
public function migrate ( ) { $ fs = new Filesystem ; $ finder = new ClassFinder ; $ path = env ( 'MIGRATIONS_PATH' , 'database/migrations' ) ; if ( $ fs -> exists ( $ path ) ) { foreach ( $ fs -> files ( $ path ) as $ file ) { $ fs -> requireOnce ( $ file ) ; $ class = $ finder -> findClass ( $ file ) ; ( new $ class ) -> up ( ) ; } } }
|
Run package database migrations .
|
16,118
|
public function isAvailable ( \ Magento \ Quote \ Api \ Data \ CartInterface $ quote = null ) { $ this -> _logger -> debug ( "isAvaliable Payapi" ) ; if ( ! $ this -> getConfigData ( 'payapi_api_key' ) || ! $ this -> getConfigData ( 'payapi_public_id' ) ) { return false ; } return parent :: isAvailable ( $ quote ) ; }
|
Determine method availability based on quote amount and config data
|
16,119
|
public static function rmVar ( $ name ) { self :: init ( ) ; if ( isset ( self :: $ variables [ $ name ] ) ) { unset ( self :: $ variables [ $ name ] ) ; } return true ; }
|
Remove variable ;
|
16,120
|
public static function getStrings ( $ names = array ( ) , $ vartype = '' ) { $ result = array ( ) ; if ( ! is_array ( $ names ) ) { return $ result ; } foreach ( $ names as $ name ) { $ result [ $ name ] = self :: getVar ( $ name , '' , $ vartype ) ; } return $ result ; }
|
Get strings array by keys ...
|
16,121
|
public function has ( $ permissions , $ all = true ) { if ( ! is_array ( $ permissions ) ) { $ permissions = ( array ) $ permissions ; } $ permissions = array_unique ( $ permissions ) ; $ filtered = array_where ( $ permissions , [ $ this , 'hasFilter' ] ) ; if ( true === $ all ) { return count ( $ permissions ) === count ( $ filtered ) ; } return 0 < count ( $ filtered ) ; }
|
Does this role have supplied permission
|
16,122
|
public static function setConfig ( array $ config ) { if ( ! isset ( $ config [ 'adapters' ] ) || ! is_array ( $ config [ 'adapters' ] ) ) { throw new DomainException ( 'Missing adapters configuration.' ) ; } $ defaultAdapter = static :: DEFAULT_ADAPTER ; if ( isset ( $ config [ 'defaults' ] [ 'adapter' ] ) ) { $ defaultAdapter = $ config [ 'defaults' ] [ 'adapter' ] ; } if ( ! isset ( $ config [ 'adapters' ] [ $ defaultAdapter ] ) ) { throw new DomainException ( sprintf ( 'Missing configuration of default adapter "%s".' , $ defaultAdapter ) ) ; } foreach ( $ config [ 'adapters' ] as $ adapter => $ items ) { if ( ! isset ( $ items [ 'class' ] ) ) { throw new DomainException ( sprintf ( 'The class of adapter "%s" is not specified.' , $ adapter ) ) ; } } static :: $ config = $ config ; }
|
Sets the configuration .
|
16,123
|
public static function make ( $ namespace = null , $ adapter = null ) { $ defaults = isset ( static :: $ config [ 'defaults' ] ) ? static :: $ config [ 'defaults' ] : [ ] ; if ( ! $ adapter ) { $ adapter = isset ( $ defaults [ 'adapter' ] ) ? $ defaults [ 'adapter' ] : static :: DEFAULT_ADAPTER ; } if ( ! isset ( static :: $ config [ 'adapters' ] [ $ adapter ] ) ) { throw new InvalidArgumentException ( sprintf ( 'Unknown type adapter of cache "%s".' , $ adapter ) ) ; } $ config = static :: $ config [ 'adapters' ] [ $ adapter ] ; $ class = $ config [ 'class' ] ; $ options = array_merge ( isset ( $ defaults [ 'options' ] ) ? ( array ) $ defaults [ 'options' ] : [ ] , isset ( $ config [ 'options' ] ) ? ( array ) $ config [ 'options' ] : [ ] ) ; if ( ! $ namespace ) { $ namespace = 'default' ; } $ options [ 'namespace' ] = $ namespace ; $ cache = new $ class ( $ options ) ; if ( ! $ cache instanceof AbstractCache ) { throw new DomainException ( sprintf ( 'The class "%s" of adapter "%s" must inherit ' . 'an "Es\Cache\AbstractCache".' , $ class , $ adapter ) ) ; } return $ cache ; }
|
Make the cache adapter .
|
16,124
|
public function init ( $ config ) { $ this -> config [ 'per_page' ] = 10 ; $ this -> config [ 'item_to_show' ] = 2 ; $ this -> config [ 'skip_item' ] = true ; $ this -> config [ 'first_tag_open' ] = "<li>" ; $ this -> config [ 'first_tag_close' ] = "</li>" ; $ this -> config [ 'last_tag_open' ] = "<li>" ; $ this -> config [ 'last_tag_close' ] = "</li>" ; $ this -> config [ 'prev_tag_open' ] = "<li>" ; $ this -> config [ 'prev_tag_close' ] = "</li>" ; $ this -> config [ 'prev_tag_text' ] = "Prev" ; $ this -> config [ 'next_tag_open' ] = "<li>" ; $ this -> config [ 'next_tag_close' ] = "</li>" ; $ this -> config [ 'next_tag_text' ] = "Next" ; $ this -> config [ 'cur_tag_open' ] = "<li class='active'>" ; $ this -> config [ 'cur_tag_close' ] = "</li>" ; $ this -> config [ 'link_attribute' ] = "class=''" ; $ this -> config [ 'link_attribute_active' ] = "class='active'" ; $ this -> config [ 'num_tag_open' ] = "<li>" ; $ this -> config [ 'num_tag_close' ] = "</li>" ; $ this -> config [ 'skip_tag_open' ] = "<li>" ; $ this -> config [ 'skip_tag_close' ] = "</li>" ; $ this -> config [ 'skip_tag_text' ] = "<a href='#'>....</a>" ; $ this -> config [ 'start_page' ] = 0 ; foreach ( $ config as $ key => $ value ) { $ this -> config [ $ key ] = $ value ; } if ( $ this -> config [ 'item_to_show' ] < 2 ) $ this -> config [ 'item_to_show' ] = 2 ; $ this -> total = intval ( $ config [ 'rows' ] ) ; $ this -> per_page = intval ( $ config [ 'per_page' ] ) ; $ this -> current_page = intval ( $ config [ 'current_page' ] ) ; $ this -> base_url = urldecode ( $ config [ 'base_url' ] ) ; }
|
Initialize pagination config
|
16,125
|
public function alias ( string $ from , string $ to , array $ params = null ) : void { if ( ! empty ( $ params ) ) { $ this -> config -> registerClassParameters ( $ to , $ params ) ; } $ this -> config -> registerClassAlias ( $ from , $ to ) ; }
|
Create a global alias for an interface .
|
16,126
|
public function singleton ( string $ className , array $ params = null ) : void { if ( ! is_null ( $ params ) ) { $ this -> config -> registerClassParameters ( $ className , $ params ) ; } $ this -> config -> registerSingleton ( $ className ) ; }
|
Treat the class as a singleton .
|
16,127
|
public function decorate ( string $ className , callable $ decorate ) : void { $ this -> config -> registerClassDecorator ( $ className , $ decorate ) ; }
|
Decorate a class .
|
16,128
|
public function factory ( string $ className , callable $ factory ) : void { $ this -> config -> registerClassFactory ( $ className , $ factory ) ; }
|
Intercept a class instantiation .
|
16,129
|
public function clear ( ) { $ key = $ this -> key ( ) ; $ files = glob ( $ this -> path . "/_cache-" . $ key . "*.cache" ) ; $ this -> setKey ( ) ; $ this -> key ( true ) ; foreach ( $ files as $ file ) { unlink ( $ file ) ; } return $ this ; }
|
Clear all of the values set by this cache instance .
|
16,130
|
public function createValue ( $ value , $ expiration ) { $ expiration = $ expiration ? str_pad ( $ expiration , 11 , "0" . STR_PAD_LEFT ) : "00000000000" ; return $ expiration . $ value ; }
|
Create a parsable value from the data and expiration date .
|
16,131
|
public function key ( $ reset = false ) { static $ key ; $ key = $ reset ? false : $ key ; if ( ! $ key ) { $ path = $ this -> path . "/.cache_key" ; if ( file_exists ( $ path ) ) { $ key = file_get_contents ( $ path ) ; } else { $ key = $ this -> setKey ( ) ; } } return $ key ; }
|
Gets the current cache namespace key .
|
16,132
|
public function setKey ( ) { $ path = $ this -> path . "/.cache_key" ; $ key = bin2hex ( openssl_random_pseudo_bytes ( 6 ) ) ; $ umask = umask ( $ this -> umask ) ; file_put_contents ( $ path , $ key ) ; umask ( $ umask ) ; return $ key ; }
|
Set the current cache key .
|
16,133
|
public function load ( CachedCollectionInterface $ routes ) { if ( ! is_file ( $ file = $ this -> getFilePath ( $ routes ) ) || filemtime ( $ file ) < $ routes -> getTimestamp ( ) ) { $ this -> dumpMap ( $ routes , $ file ) ; } return $ this -> loadMap ( $ file ) ; }
|
Get the statuc route map .
|
16,134
|
public function setTemplate ( $ template ) { $ layout = $ this -> getViewModel ( ) ; $ layout -> setTemplate ( ( string ) $ template ) ; return $ this ; }
|
Sets the layout template .
|
16,135
|
public function setModule ( $ module ) { $ layout = $ this -> getViewModel ( ) ; $ layout -> setModule ( ( string ) $ module ) ; return $ this ; }
|
Sets the layout module name .
|
16,136
|
public function getView ( $ view ) { $ path = explode ( "/" , $ view ) ; include ( count ( $ path ) > 1 ) ? "src/views/" . $ path [ 0 ] . "/" . $ path [ 1 ] . ".php" : "src/views/" . $ path [ 0 ] . "/index.php" ; }
|
view being called is in the views directory additional directories are taken into account .
|
16,137
|
public function get ( ) { if ( ! $ this -> isTracking ( ) ) { return false ; } $ statusPacket = json_decode ( $ this -> resqueInstance -> redis -> get ( ( string ) $ this ) , true ) ; if ( ! $ statusPacket ) { return false ; } return $ statusPacket [ 'status' ] ; }
|
Fetch the status for the job being monitored .
|
16,138
|
public function setCredentials ( ? string $ gApiServiceAccountCredentialsFilePath = null ) : string { $ this -> client = null ; $ this -> getClient ( $ gApiServiceAccountCredentialsFilePath ) ; return $ this -> getCredentialsFilePath ( ) ; }
|
A helper method allowing to use different credentials during the lifecycle of the application .
|
16,139
|
public function getMapping ( ) { if ( null === $ this -> mapping ) { $ mappingFilePath = $ this -> locateFile ( $ this -> mappingFileName ) ; if ( is_array ( $ mappingFilePath ) ) { throw new \ Exception ( "The mapping file wasn't found. Locations we tried: " . join ( ', ' , $ mappingFilePath ) ) ; } elseif ( ! is_readable ( $ mappingFilePath ) ) { throw new \ RuntimeException ( sprintf ( 'The mapping.yaml was not found at %s or is not readable.' , $ mappingFilePath ) ) ; } else { $ this -> mappingFilePath = $ mappingFilePath ; $ this -> mapping = Yaml :: parse ( file_get_contents ( $ mappingFilePath ) ) ; } } return $ this -> mapping ; }
|
Returns the array resulting from mapping . yaml .
|
16,140
|
private function locateFile ( $ fileName , ? string $ userSuppliedPath = null ) { $ locations = [ $ this -> projectDir . DIRECTORY_SEPARATOR . $ fileName , ] ; if ( getcwd ( ) !== $ this -> projectDir ) { $ locations [ ] = getcwd ( ) . DIRECTORY_SEPARATOR . $ fileName ; } $ locationsFailed = [ ] ; if ( null !== $ userSuppliedPath ) { array_unshift ( $ locations , $ userSuppliedPath ) ; } for ( $ loop = 1 ; $ loop <= 2 ; ++ $ loop ) { while ( $ path = array_shift ( $ locations ) ) { if ( file_exists ( $ path ) && is_readable ( $ path ) ) { return $ path ; } $ locationsFailed [ ] = $ path ; } if ( 1 === $ loop ) { $ locations [ ] = DIRECTORY_SEPARATOR . $ fileName ; foreach ( [ $ this -> projectDir , getcwd ( ) ] as $ leafDirectory ) { $ path = '/' ; foreach ( array_filter ( explode ( DIRECTORY_SEPARATOR , dirname ( $ leafDirectory ) ) ) as $ directory ) { $ path .= $ directory . DIRECTORY_SEPARATOR ; if ( false === array_search ( $ path . $ fileName , $ locationsFailed ) && false === array_search ( $ path . $ fileName , $ locations ) && is_dir ( $ path ) && is_readable ( $ path ) ) { array_unshift ( $ locations , $ path . $ fileName ) ; } } } } } return $ locationsFailed ; }
|
Looks for a specified file name in various locations .
|
16,141
|
public function error ( Base $ app , array $ params ) { $ eol = PHP_EOL ; $ req = $ app [ 'VERB' ] . ' ' . $ app [ 'PATH' ] ; $ error = ( $ app [ 'ERROR' ] ? : [ ] ) + [ 'text' => 'No-Message' , 'trace' => 'No-Trace' , 'status' => 'No-Status' , 'code' => '000' , ] ; $ this -> log ( sprintf ( "[%s] %s %s" , $ req , $ error [ 'text' ] ? : 'No-Message' , $ error [ 'trace' ] ) ) ; if ( $ app [ 'CLI' ] ) { return ; } if ( $ app [ 'AJAX' ] ) { echo json_decode ( $ error ) ; return ; } if ( $ app [ 'ERROR_TEMPLATE' ] ) { echo ExtendedTemplate :: instance ( ) -> render ( $ app [ 'ERROR_TEMPLATE' ] ) ; return ; } echo '<!DOCTYPE html>' . $ eol . '<html lang="en">' . $ eol . '<head>' . $ eol . '<meta charset="utf-8">' . $ eol . '<meta http-equiv="X-UA-Compatible" content="IE=edge">' . $ eol . '<meta name="viewport" content="width=device-width, initial-scale=1">' . $ eol . '<meta name="author" content="Eko Kurniawan">' . $ eol . '<title>' . $ error [ 'code' ] . ' ' . $ error [ 'status' ] . '</title>' . $ eol . '<style>' . $ eol . 'code{word-wrap:break-word;color:black}.comment,.doc_comment,.ml_comment{color:dimgray;font-style:italic}.variable{color:blueviolet}.const,.constant_encapsed_string,.class_c,.dir,.file,.func_c,.halt_compiler,.line,.method_c,.lnumber,.dnumber{color:crimson}.string,.and_equal,.boolean_and,.boolean_or,.concat_equal,.dec,.div_equal,.inc,.is_equal,.is_greater_or_equal,.is_identical,.is_not_equal,.is_not_identical,.is_smaller_or_equal,.logical_and,.logical_or,.logical_xor,.minus_equal,.mod_equal,.mul_equal,.ns_c,.ns_separator,.or_equal,.plus_equal,.sl,.sl_equal,.sr,.sr_equal,.xor_equal,.start_heredoc,.end_heredoc,.object_operator,.paamayim_nekudotayim{color:black}.abstract,.array,.array_cast,.as,.break,.case,.catch,.class,.clone,.continue,.declare,.default,.do,.echo,.else,.elseif,.empty.enddeclare,.endfor,.endforach,.endif,.endswitch,.endwhile,.eval,.exit,.extends,.final,.for,.foreach,.function,.global,.goto,.if,.implements,.include,.include_once,.instanceof,.interface,.isset,.list,.namespace,.new,.print,.private,.public,.protected,.require,.require_once,.return,.static,.switch,.throw,.try,.unset,.use,.var,.while{color:royalblue}.open_tag,.open_tag_with_echo,.close_tag{color:orange}.ini_section{color:black}.ini_key{color:royalblue}.ini_value{color:crimson}.xml_tag{color:dodgerblue}.xml_attr{color:blueviolet}.xml_data{color:red}.section{color:black}.directive{color:blue}.data{color:dimgray}' . '</style>' . $ eol . '</head>' . $ eol . '<body>' . $ eol . '<h1>' . $ error [ 'status' ] . '</h1>' . $ eol . '<p>' . $ app -> encode ( $ error [ 'text' ] ? : $ req ) . '</p>' . $ eol . ( $ app [ 'DEBUG' ] ? ( '<pre>' . $ error [ 'trace' ] . '</pre>' . $ eol ) : '' ) . '</body>' . $ eol . '</html>' ; }
|
Custom error handler with ability to log error and its trace
|
16,142
|
private function _loadRoles ( array $ aclConfig ) { foreach ( $ aclConfig as $ role => $ acl ) { if ( isset ( $ acl [ self :: CONFIG_FIELD_RESOURCE ] ) and is_array ( $ acl [ self :: CONFIG_FIELD_RESOURCE ] ) ) { $ this -> _roles [ $ role ] = $ acl [ self :: CONFIG_FIELD_RESOURCE ] ; } else { $ this -> _roles [ $ role ] = array ( ) ; } if ( isset ( $ acl [ self :: CONFIG_FIELD_INHERIT ] ) and is_array ( $ acl [ self :: CONFIG_FIELD_INHERIT ] ) ) { foreach ( $ acl [ self :: CONFIG_FIELD_INHERIT ] as $ inherit ) { if ( isset ( $ aclConfig [ $ inherit ] [ self :: CONFIG_FIELD_RESOURCE ] ) and is_array ( $ aclConfig [ $ inherit ] [ self :: CONFIG_FIELD_RESOURCE ] ) ) { $ this -> _roles [ $ role ] = array_merge ( $ this -> _roles [ $ role ] , $ aclConfig [ $ inherit ] [ self :: CONFIG_FIELD_RESOURCE ] ) ; } } } } return $ this -> _roles ; }
|
Load the roles from the ACL configuration file .
|
16,143
|
public function isAllowed ( $ pRole , array $ pResources ) { foreach ( $ pResources as $ resource ) { if ( ! isset ( $ this -> _roles [ $ pRole ] ) or ! in_array ( $ resource , $ this -> _roles [ $ pRole ] ) ) { return false ; } } return true ; }
|
Check if the role exists and if the resource is available with this role .
|
16,144
|
public function decode ( array $ options = [ ] ) { $ json = json_decode ( $ this -> getContents ( ) , true ) ; if ( $ json === null && json_last_error ( ) === JSON_ERROR_NONE ) { $ this -> validateSyntax ( ) ; return $ this ; } $ this -> validateSchema ( ) ; return $ json ; }
|
Decodes JSON data .
|
16,145
|
protected function validateSchema ( ) { $ schemaPath = $ this -> getOption ( 'schemaPath' ) ; if ( $ schemaPath === null ) { return ; } $ schemaData = json_decode ( file_get_contents ( $ schemaPath ) ) ; if ( ! class_exists ( '\\JsonSchema\\Validator' ) ) { throw new \ RuntimeException ( 'If you want to validate a JSON schema, you must require package "justinrainbow/json-schema"-' ) ; } $ validator = new \ JsonSchema \ Validator ( ) ; $ validator -> check ( $ this -> getContents ( ) , $ schemaData ) ; if ( ! $ validator -> isValid ( ) ) { $ errors = [ ] ; foreach ( ( array ) $ validator -> getErrors ( ) as $ error ) { $ errors [ ] = ( $ error [ 'property' ] ? $ error [ 'property' ] . ' : ' : '' ) . $ error [ 'message' ] ; } throw DecodeException :: create ( $ this -> getPath ( ) , [ 'errors' => $ errors ] ) ; } }
|
Validates JSON schema .
|
16,146
|
protected function validateSyntax ( ) { if ( ! class_exists ( '\\Seld\\JsonLint\\JsonParser' ) ) { throw new \ RuntimeException ( 'If you want to validate JSON syntax using lint, you must require package "seld/jsonlint".' ) ; } $ parser = new \ Seld \ JsonLint \ JsonParser ( ) ; $ result = $ parser -> lint ( $ this -> getContents ( ) ) ; if ( $ result === null ) { if ( JSON_ERROR_UTF8 === json_last_error ( ) ) { throw new \ UnexpectedValueException ( '"' . $ this -> getPath ( ) . '" is not encoded in UTF-8, could not parse as JSON' ) ; } return true ; } throw DecodeException :: create ( $ this -> getPath ( ) , [ 'message' => $ result -> getMessage ( ) , 'details' => $ result -> getDetails ( ) ] ) ; }
|
Validates JSON syntax using lint .
|
16,147
|
public function addSimpleCondition ( string $ p_operator , string $ p_left , $ p_right = null ) { $ condition = \ FreeFW \ DI \ DI :: get ( 'FreeFW::Model::Condition' ) ; $ left = null ; if ( strpos ( $ p_left , '::Model::' ) !== false ) { $ left = new \ FreeFW \ Model \ ConditionMember ( ) ; $ left -> setField ( $ p_left ) ; } else { $ left = new \ FreeFW \ Model \ ConditionValue ( ) ; $ left -> setField ( $ p_left ) ; } $ right = null ; if ( $ p_right !== null ) { if ( strpos ( $ p_right , '::Model::' ) !== false ) { $ right = new \ FreeFW \ Model \ ConditionMember ( ) ; $ right -> setField ( $ p_right ) ; } else { $ right = new \ FreeFW \ Model \ ConditionValue ( ) ; $ right -> setField ( $ p_right ) ; } } $ condition -> setLeftMember ( $ left ) -> setOperator ( $ p_operator ) ; if ( $ right !== null ) { $ condition -> setRightMember ( $ right ) ; } return $ this -> addCondition ( $ condition ) ; }
|
Add simple condition
|
16,148
|
public function conditionLower ( string $ p_member , $ p_value ) { return $ this -> addSimpleCondition ( \ FreeFW \ Storage \ Storage :: COND_LOWER , $ p_member , $ p_value ) ; }
|
Simple lower condition
|
16,149
|
public function search ( $ key ) { $ splitOffset = $ this -> getSplitOffset ( ) ; $ keys = $ this -> index -> getKeyReader ( ) -> readKeys ( $ splitOffset , self :: DIRECTION_FORWARD ) ; $ foundKey = $ this -> findKey ( $ key , $ keys ) ; if ( ! is_null ( $ foundKey ) ) { return $ foundKey ; } if ( $ this -> isKeyRange ( $ key , $ keys ) ) { return \ reset ( $ keys ) ; } if ( ! empty ( $ keys ) && \ end ( $ keys ) -> getKey ( ) < $ key ) { $ newOffset = $ splitOffset + $ this -> index -> getKeyReader ( ) -> getReadLength ( ) ; if ( $ newOffset >= $ this -> index -> getFile ( ) -> getFileSize ( ) ) { return \ end ( $ keys ) ; } $ newLength = $ this -> range -> getLength ( ) - ( $ newOffset - $ this -> range -> getOffset ( ) ) ; $ this -> range -> setOffset ( $ newOffset ) ; $ this -> range -> setLength ( $ newLength ) ; return $ this -> search ( $ key ) ; } $ centerKeyOffset = empty ( $ keys ) ? $ this -> range -> getNextByteOffset ( ) : \ reset ( $ keys ) -> getOffset ( ) ; $ keys = $ this -> index -> getKeyReader ( ) -> readKeys ( $ centerKeyOffset , self :: DIRECTION_BACKWARD ) ; $ foundKey = $ this -> findKey ( $ key , $ keys ) ; if ( ! is_null ( $ foundKey ) ) { return $ foundKey ; } if ( empty ( $ keys ) ) { return null ; } if ( $ this -> isKeyRange ( $ key , $ keys ) ) { return \ reset ( $ keys ) ; } $ newLength = \ reset ( $ keys ) -> getOffset ( ) - $ this -> range -> getOffset ( ) - 1 ; if ( $ newLength >= $ this -> range -> getLength ( ) ) { return \ reset ( $ keys ) ; } $ this -> range -> setLength ( $ newLength ) ; return $ this -> search ( $ key ) ; }
|
Searches for a key or some neighbour
|
16,150
|
private function isKeyRange ( $ key , Array $ keys ) { if ( empty ( $ keys ) ) { return false ; } return \ reset ( $ keys ) -> getKey ( ) <= $ key && \ end ( $ keys ) -> getKey ( ) >= $ key ; }
|
Returns true if the key is expected to be in the key list
|
16,151
|
private function getSplitOffset ( ) { $ blocks = ( int ) $ this -> range -> getLength ( ) / $ this -> index -> getKeyReader ( ) -> getReadLength ( ) ; $ centerBlock = ( int ) $ blocks / 2 ; return $ this -> range -> getOffset ( ) + $ centerBlock * $ this -> index -> getKeyReader ( ) -> getReadLength ( ) ; }
|
Returns the offset for the split
|
16,152
|
public static function execute ( $ q ) { if ( ! isset ( self :: $ pest ) ) $ p = new \ Pest ( self :: API ) ; $ json = $ p -> get ( '' , [ 'q' => $ q , 'format' => 'json' , 'diagnostics' => false , 'env' => 'http://datatables.org/alltables.env' , ] ) ; return new Result ( $ json ) ; }
|
Runs the Query against Yahoo s Database
|
16,153
|
private function writeLine ( $ text , $ indent = 0 ) { $ indent = strlen ( $ text ) + $ indent ; $ format = '%' . $ indent . 's' ; $ this -> reference .= sprintf ( $ format , $ text ) . PHP_EOL ; }
|
Outputs a single config reference line .
|
16,154
|
public function parse ( array $ criteria , array $ orderBy = array ( ) , $ limit = null , $ offset = null ) { $ statement = new Expr \ Statement ( ) ; if ( ! empty ( $ criteria ) ) { $ statement -> setClause ( 'condition' , $ this -> parseCriteria ( $ criteria ) ) ; } if ( ! empty ( $ orderBy ) ) $ statement -> setClause ( 'order' , $ this -> parseOrderBy ( $ orderBy ) ) ; if ( $ limit ) $ statement -> setClause ( 'limit' , $ this -> parseLimit ( $ limit ) ) ; if ( $ offset ) $ statement -> setClause ( 'offset' , $ this -> parseOffset ( $ offset ) ) ; return new Query ( $ statement , $ this -> persister ) ; }
|
parse Parse fields criteria and order
|
16,155
|
protected function parseOrXValues ( $ field , $ values ) { $ exprs = array ( ) ; foreach ( $ values as $ value ) { $ exprs [ ] = $ this -> parseFieldValue ( $ field , $ value ) ; } return $ this -> expr ( ) -> orX ( $ exprs ) ; }
|
parseOrXValues parse deep array as a orx
|
16,156
|
public function set ( array $ pairs ) { foreach ( $ pairs as $ column => $ value ) { $ this -> _set [ ] = array ( $ column , $ value ) ; } return $ this ; }
|
Set the values to update with an associative array .
|
16,157
|
public function on ( $ c1 , $ op , $ c2 ) { $ this -> _last_join -> on ( $ c1 , $ op , $ c2 ) ; return $ this ; }
|
Adds ON ... conditions for the last created JOIN statement .
|
16,158
|
public function callProtectedMethod ( $ object , string $ method , array $ arguments = [ ] ) { if ( ! is_object ( $ object ) ) { $ msg = $ this -> getErrorMessage ( 1 , __METHOD__ , $ object ) ; throw new InvalidArgumentException ( $ msg ) ; } $ class = new ReflectionClass ( $ object ) ; $ method = $ class -> getMethod ( $ method ) ; $ method -> setAccessible ( true ) ; return $ method -> invokeArgs ( $ object , $ arguments ) ; }
|
Calls a protected or private method and returns its result .
|
16,159
|
public function onCssLastModified ( ContentEvent $ event ) { $ reflection = new \ ReflectionClass ( get_class ( $ this ) ) ; if ( strpos ( $ reflection -> getFileName ( ) , '/cache/' ) ) { $ dir = dirname ( $ reflection -> getFileName ( ) ) . '/../../..' ; } else { $ dir = dirname ( $ reflection -> getFileName ( ) ) . '/../../../../../..' ; } if ( get_class ( $ this ) != "eDemy\MainBundle\Controller\MainController" ) { } $ finder = new Finder ( ) ; $ finder -> files ( ) -> in ( $ dir . '/vendor/edemy/mainbundle/eDemy/*/Resources/views/assets' ) -> name ( '*.css.twig' ) -> sortByModifiedTime ( ) ; foreach ( $ finder as $ file ) { $ lastmodified = \ DateTime :: createFromFormat ( 'U' , $ file -> getMTime ( ) ) ; if ( $ event -> getLastModified ( ) > $ lastmodified ) { } else { $ event -> setLastModified ( $ lastmodified ) ; } } }
|
Este listener calcula lastmodified de la ruta
|
16,160
|
public function hasPermission ( $ permission ) { if ( ! is_array ( $ this -> permissionsMap ) ) { $ permissionsMap = cache ( ) -> get ( 'permissions:' . $ this -> id , null ) ; if ( $ permissionsMap === null ) { $ this -> permissionsMap = $ this -> buildPermissionsMap ( ) ; cache ( ) -> forever ( 'permissions:' . $ this -> id , $ this -> permissionsMap ) ; } else { $ this -> permissionsMap = $ permissionsMap ; } } return in_array ( $ permission , $ this -> permissionsMap ) ; }
|
It checks if given user have specified permission
|
16,161
|
private function buildPermissionsMap ( ) { $ permissionsMap = [ ] ; $ roles = $ this -> roles ( ) -> with ( 'permissions' ) -> get ( ) -> toArray ( ) ; foreach ( $ roles as $ role ) { if ( ! empty ( $ role [ 'permissions' ] ) ) { foreach ( $ role [ 'permissions' ] as $ permission ) { $ permissionsMap [ ] = $ permission [ 'name' ] ; } } } return array_unique ( $ permissionsMap ) ; }
|
It build permission map . Later we store this map cache .
|
16,162
|
public function singleton ( $ className ) { $ closure = function ( ContainerInterface $ container ) use ( $ className ) { static $ instance ; if ( is_null ( $ instance ) ) { $ instance = $ container -> make ( $ className ) ; } return $ instance ; } ; $ this -> bind ( $ className , $ closure ) ; }
|
Register a shared binding
|
16,163
|
public function resolve ( $ key ) { if ( ! array_key_exists ( $ key , $ this -> bindings ) ) { throw new InvalidArgumentException ( "{$key} is not bound." ) ; } $ binding = $ this -> bindings [ $ key ] ; $ value = $ binding [ 'value' ] ; if ( $ value instanceof Closure ) { return $ value ( $ this ) ; } if ( is_null ( $ value ) && class_exists ( '\\' . $ key ) ) { return $ this -> make ( $ key ) ; } if ( is_string ( $ value ) && class_exists ( '\\' . $ value ) ) { return $ this -> make ( $ value ) ; } return $ value ; }
|
Resolve the value from the given offset
|
16,164
|
protected function getDependencies ( ReflectionClass $ refl ) { if ( ! $ refl -> isInstantiable ( ) ) { return [ ] ; } $ constr = $ refl -> getConstructor ( ) ; if ( ! $ constr ) { return [ ] ; } return $ constr -> getParameters ( ) ; }
|
Get an array of object dependencies
|
16,165
|
protected function resolveDependency ( ReflectionParameter $ dep ) { $ depName = $ dep -> getName ( ) ; if ( $ dep -> getClass ( ) ) { $ depName = $ dep -> getClass ( ) -> name ; } if ( array_key_exists ( $ depName , $ this -> bindings ) ) { return $ this -> resolve ( $ depName ) ; } if ( class_exists ( '\\' . $ depName ) ) { return $ this -> make ( $ depName ) ; } if ( $ dep -> isDefaultValueAvailable ( ) ) { return $ dep -> getDefaultValue ( ) ; } throw new ResolutionException ( "Unable to resolve dependency {$depName} for {$dep->getDeclaringClass()->name}" ) ; }
|
Resolve object dependency
|
16,166
|
public function getVersionString ( $ bits = null ) { if ( is_null ( $ bits ) ) { return $ this -> version ; } return implode ( '.' , $ this -> versionFromBits ( $ bits ) ) ; }
|
Get the version number as a dot seperated string .
|
16,167
|
private function extractVersion ( ) { $ git = Executable :: make ( $ this -> gitBin ) -> addArgument ( sprintf ( '--git-dir=%s' , $ this -> gitPath ) ) -> addArgument ( 'describe' ) -> addArgument ( '--tags' ) -> addArgument ( '--always' ) ; try { $ git -> execute ( ) ; } catch ( \ Ballen \ Executioner \ Exceptions \ ExecutionException $ exception ) { } $ version = trim ( $ git -> resultAsText ( ) ) ; $ this -> version = '0.0.0-0-' . $ version ; if ( strlen ( $ version ) > 7 ) { $ this -> version = str_replace ( 'v' , '' , $ version ) ; } $ this -> versionBits ( ) ; }
|
Extracts the version from the Git repository .
|
16,168
|
private function versionBits ( ) { $ versionBits = explode ( '-' , $ this -> version ) ; if ( strlen ( $ versionBits [ 0 ] ) ) { $ this -> version = $ versionBits [ 0 ] ; if ( isset ( $ versionBits [ 1 ] ) ) { $ this -> version = $ versionBits [ 0 ] . '.' . $ versionBits [ 1 ] ; } if ( isset ( $ versionBits [ 2 ] ) ) { $ this -> hash = $ versionBits [ 2 ] ; } } }
|
Computes and sets the version number and object hash properties .
|
16,169
|
private function versionFromBits ( $ bits ) { $ version = [ ] ; foreach ( range ( 0 , ( $ bits - 1 ) ) as $ bit ) { $ version [ $ bit ] = $ this -> getVersionBits ( ) [ $ bit ] ; } return $ version ; }
|
Returns an customised array of the total number of version bits .
|
16,170
|
public function load ( array $ configs , ContainerBuilder $ container ) { $ loader = new XmlFileLoader ( $ container , new FileLocator ( __DIR__ . '/../Resources/config' ) ) ; $ loader -> load ( 'converter.xml' ) ; $ loader -> load ( 'event.xml' ) ; $ loader -> load ( 'event_listeners.xml' ) ; $ loader -> load ( 'command.xml' ) ; $ loader -> load ( 'indexer.xml' ) ; $ loader -> load ( 'queue.xml' ) ; $ loader -> load ( 'solarium.xml' ) ; $ loader -> load ( 'task.xml' ) ; $ loader -> load ( 'types.xml' ) ; $ loader -> load ( 'worker.xml' ) ; if ( $ container -> getParameter ( 'kernel.debug' ) ) { $ loader -> load ( 'collector.xml' ) ; } $ configuration = new Configuration ( ) ; $ config = $ this -> processConfiguration ( $ configuration , $ configs ) ; $ endpoints = [ ] ; foreach ( $ config [ 'endpoints' ] as $ name => $ options ) { $ options [ 'key' ] = $ name ; $ container -> setDefinition ( 'solarium.client.endpoint.' . $ name , new Definition ( Endpoint :: class , [ $ options ] ) ) ; $ endpoints [ ] = new Reference ( 'solarium.client.endpoint.' . $ name ) ; } $ container -> setDefinition ( 'solarium.client' , new Definition ( Client :: class , [ [ 'endpoint' => $ endpoints ] , new Reference ( 'integrated_solr.event.dispatcher' ) ] ) ) ; if ( $ container -> getParameter ( 'kernel.debug' ) ) { $ container -> getDefinition ( 'solarium.client' ) -> addMethodCall ( 'registerPlugin' , [ 'solarium.client.logger' , new Reference ( 'integrated_solr.solarium.data_collector' ) ] ) ; } }
|
Load the configuration
|
16,171
|
public function setEmail ( $ email ) { $ email = is_null ( $ email ) ? '' : $ email ; parent :: setEmail ( $ email ) ; $ this -> setUsername ( $ email ) ; return $ this ; }
|
Set email Also sets the username to the email
|
16,172
|
public function login ( $ force = false ) { if ( ! $ force && static :: isLogged ( ) ) { static :: throwException ( 'alreadyLoggedin' ) ; } global $ USER ; $ _SESSION [ 'USER' ] = $ USER = $ this ; $ this -> login = $ force ? self :: LOGGED_FORCED : self :: IS_LOGGED ; if ( ! $ force ) { static :: logEvent ( 'login' ) ; } static :: logEvent ( 'activity' ) ; }
|
Log in this user to the current session .
|
16,173
|
public function logout ( $ reason = null ) { global $ USER ; if ( ! $ this -> login ) { return false ; } $ this -> login = self :: NOT_LOGGED ; $ _SESSION [ 'USER' ] = $ USER = null ; $ _SESSION [ 'LOGOUT_REASON' ] = $ reason ; return true ; }
|
Log out this user from the current session .
|
16,174
|
public function checkAccess ( $ module ) { if ( ! isset ( $ GLOBALS [ 'ACCESS' ] -> $ module ) ) { return true ; } return $ this -> checkPerm ( ( int ) $ GLOBALS [ 'ACCESS' ] -> $ module ) ; }
|
Check access permissions
|
16,175
|
public function canDo ( $ action , $ object = null ) { return $ this -> equals ( $ object ) || ( $ this -> checkPerm ( $ action ) && ( ! ( $ object instanceof AbstractUser ) || $ this -> canAlter ( $ object ) ) ) ; }
|
Check if this user can affect data on the given user
|
16,176
|
public static function userLogin ( $ data , $ loginField = 'email' ) { if ( empty ( $ data [ $ loginField ] ) ) { static :: throwException ( 'invalidLoginID' ) ; } $ name = $ data [ $ loginField ] ; if ( empty ( $ data [ 'password' ] ) ) { static :: throwException ( 'invalidPassword' ) ; } $ password = hashString ( $ data [ 'password' ] ) ; $ user = static :: get ( array ( 'where' => static :: formatValue ( $ name ) . ' IN (' . implode ( ',' , static :: listLoginFields ( ) ) . ')' , 'number' => 1 , 'output' => SQLAdapter :: OBJECT ) ) ; if ( empty ( $ user ) ) { static :: throwException ( "invalidLoginID" ) ; } if ( isset ( $ user -> published ) && ! $ user -> published ) { static :: throwException ( 'forbiddenLogin' ) ; } if ( $ user -> password != $ password ) { static :: throwException ( 'wrongPassword' ) ; } $ user -> logout ( ) ; $ user -> login ( ) ; return $ user ; }
|
Logs in an user using data
|
16,177
|
public static function httpLogin ( ) { $ user = static :: get ( array ( 'where' => 'name LIKE ' . static :: formatValue ( $ _SERVER [ 'PHP_AUTH_USER' ] ) , 'output' => SQLAdapter :: OBJECT ) ) ; if ( empty ( $ user ) ) { static :: throwNotFound ( ) ; } if ( $ user -> password != static :: hashPassword ( $ _SERVER [ 'PHP_AUTH_PW' ] ) ) { static :: throwException ( "wrongPassword" ) ; } $ user -> logout ( ) ; $ user -> login ( ) ; }
|
Log in an user from HTTP authentication according to server variables PHP_AUTH_USER and PHP_AUTH_PW
|
16,178
|
public static function httpAuthenticate ( ) { try { static :: httpLogin ( ) ; return true ; } catch ( NotFoundException $ e ) { if ( Config :: get ( 'httpauth_autocreate' ) ) { $ user = static :: httpCreate ( ) ; $ user -> login ( ) ; return true ; } } catch ( UserException $ e ) { } return false ; }
|
Login from HTTP authentication create user if not existing
|
16,179
|
public static function load ( $ id , $ nullable = true , $ usingCache = true ) { if ( static :: getLoggedUserID ( ) == $ id ) { return $ GLOBALS [ 'USER' ] ; } return parent :: load ( $ id , $ nullable , $ usingCache ) ; }
|
Load an user object
|
16,180
|
public static function loggedCanAccessToRoute ( $ route , $ accesslevel ) { $ user = static :: getLoggedUser ( ) ; if ( ! ctype_digit ( $ accesslevel ) ) { $ accesslevel = static :: getRoleAccesslevel ( $ accesslevel ) ; } $ accesslevel = ( int ) $ accesslevel ; return ( empty ( $ user ) && $ accesslevel < 0 ) || ( ! empty ( $ user ) && $ accesslevel >= 0 && $ user instanceof AbstractUser && $ user -> checkPerm ( $ accesslevel ) ) ; }
|
Check if this user can access to a module
|
16,181
|
public static function loggedHasDeveloperAccess ( ) { $ user = static :: getLoggedUser ( ) ; $ requiredAccessLevel = ( int ) static :: getRoleAccesslevel ( 'developer' ) ; return $ user && $ user -> checkPerm ( $ requiredAccessLevel ) ; }
|
Check if this user has developer access
|
16,182
|
public static function loggedCanDo ( $ action , AbstractUser $ object = null ) { global $ USER ; return ! empty ( $ USER ) && $ USER -> canDo ( $ action , $ object ) ; }
|
Check if this user can do a restricted action
|
16,183
|
public static function checkForObject ( $ data , $ ref = null ) { if ( empty ( $ data [ 'email' ] ) ) { return ; } $ where = 'email LIKE ' . static :: formatValue ( $ data [ 'email' ] ) ; $ what = 'email' ; if ( ! empty ( $ data [ 'name' ] ) ) { $ what .= ', name' ; $ where .= ' OR name LIKE ' . static :: formatValue ( $ data [ 'name' ] ) ; } $ user = static :: get ( array ( 'what' => $ what , 'where' => $ where , 'output' => SQLAdapter :: ARR_FIRST ) ) ; if ( ! empty ( $ user ) ) { if ( $ user [ 'email' ] === $ data [ 'email' ] ) { static :: throwException ( "emailAlreadyUsed" ) ; } else { static :: throwException ( "entryExisting" ) ; } } }
|
Check for object
|
16,184
|
private static function localeNumber ( $ number , int $ decimal = 2 ) : string { return Number :: getNumber ( self :: prepareFloat ( $ number ) , $ decimal ) ; }
|
Vrati zformatovane cislo
|
16,185
|
private static function localeDateTime ( $ datetime , bool $ withSeconds = false ) : string { return Date :: getDateTime ( $ datetime , $ withSeconds ) ; }
|
Lokalizovane datum s casem
|
16,186
|
public function aggregate ( array $ pipeline , array $ options = array ( ) ) { if ( ! array_key_exists ( 0 , $ pipeline ) ) { $ pipeline = func_get_args ( ) ; $ options = array ( ) ; } if ( $ this -> eventManager -> hasListeners ( Events :: preAggregate ) ) { $ this -> eventManager -> dispatchEvent ( Events :: preAggregate , new AggregateEventArgs ( $ this , $ pipeline , $ options ) ) ; } $ result = $ this -> doAggregate ( $ pipeline , $ options ) ; if ( $ this -> eventManager -> hasListeners ( Events :: postAggregate ) ) { $ eventArgs = new MutableEventArgs ( $ this , $ result ) ; $ this -> eventManager -> dispatchEvent ( Events :: postAggregate , $ eventArgs ) ; $ result = $ eventArgs -> getData ( ) ; } return $ result ; }
|
Invokes the aggregate command .
|
16,187
|
public function count ( array $ query = array ( ) , $ limitOrOptions = 0 , $ skip = 0 ) { $ options = is_array ( $ limitOrOptions ) ? array_merge ( array ( 'limit' => 0 , 'skip' => 0 ) , $ limitOrOptions ) : array ( 'limit' => $ limitOrOptions , 'skip' => $ skip ) ; $ options [ 'limit' ] = ( integer ) $ options [ 'limit' ] ; $ options [ 'skip' ] = ( integer ) $ options [ 'skip' ] ; return $ this -> doCount ( $ query , $ options ) ; }
|
Invokes the count command .
|
16,188
|
public function distinct ( $ field , array $ query = array ( ) , array $ options = array ( ) ) { if ( $ this -> eventManager -> hasListeners ( Events :: preDistinct ) ) { $ this -> eventManager -> dispatchEvent ( Events :: preDistinct , new DistinctEventArgs ( $ this , $ field , $ query ) ) ; } $ result = $ this -> doDistinct ( $ field , $ query , $ options ) ; if ( $ this -> eventManager -> hasListeners ( Events :: postDistinct ) ) { $ eventArgs = new MutableEventArgs ( $ this , $ result ) ; $ this -> eventManager -> dispatchEvent ( Events :: postDistinct , $ eventArgs ) ; $ result = $ eventArgs -> getData ( ) ; } return $ result ; }
|
Invokes the distinct command .
|
16,189
|
public function near ( $ near , array $ query = array ( ) , array $ options = array ( ) ) { if ( $ this -> eventManager -> hasListeners ( Events :: preNear ) ) { $ this -> eventManager -> dispatchEvent ( Events :: preNear , new NearEventArgs ( $ this , $ query , $ near , $ options ) ) ; } $ result = $ this -> doNear ( $ near , $ query , $ options ) ; if ( $ this -> eventManager -> hasListeners ( Events :: postNear ) ) { $ eventArgs = new MutableEventArgs ( $ this , $ result ) ; $ this -> eventManager -> dispatchEvent ( Events :: postNear , $ eventArgs ) ; $ result = $ eventArgs -> getData ( ) ; } return $ result ; }
|
Invokes the geoNear command .
|
16,190
|
protected function doAggregate ( array $ pipeline , array $ options = array ( ) ) { if ( isset ( $ options [ 'cursor' ] ) && ( $ options [ 'cursor' ] || is_array ( $ options [ 'cursor' ] ) ) ) { return $ this -> doAggregateCursor ( $ pipeline , $ options ) ; } unset ( $ options [ 'cursor' ] ) ; list ( $ commandOptions , $ clientOptions ) = isset ( $ options [ 'socketTimeoutMS' ] ) || isset ( $ options [ 'timeout' ] ) ? $ this -> splitCommandAndClientOptions ( $ options ) : array ( $ options , array ( ) ) ; $ command = array ( ) ; $ command [ 'aggregate' ] = $ this -> riakCollection -> getName ( ) ; $ command [ 'pipeline' ] = $ pipeline ; $ command = array_merge ( $ command , $ commandOptions ) ; $ database = $ this -> database ; $ result = $ this -> retry ( function ( ) use ( $ database , $ command , $ clientOptions ) { return $ database -> command ( $ command , $ clientOptions ) ; } ) ; if ( empty ( $ result [ 'ok' ] ) ) { throw new ResultException ( $ result ) ; } if ( isset ( $ pipeline [ count ( $ pipeline ) - 1 ] [ '$out' ] ) ) { $ outputCollection = $ pipeline [ count ( $ pipeline ) - 1 ] [ '$out' ] ; return $ database -> selectCollection ( $ outputCollection ) -> find ( ) ; } $ arrayIterator = new ArrayIterator ( isset ( $ result [ 'result' ] ) ? $ result [ 'result' ] : array ( ) ) ; $ arrayIterator -> setCommandResult ( $ result ) ; return $ arrayIterator ; }
|
Execute the aggregate command .
|
16,191
|
protected function doAggregateCursor ( array $ pipeline , array $ options = array ( ) ) { if ( ! method_exists ( 'RiakCollection' , 'aggregateCursor' ) ) { throw new BadMethodCallException ( 'RiakCollection::aggregateCursor() is not available' ) ; } list ( $ commandOptions , $ clientOptions ) = isset ( $ options [ 'socketTimeoutMS' ] ) || isset ( $ options [ 'timeout' ] ) ? $ this -> splitCommandAndClientOptions ( $ options ) : array ( $ options , array ( ) ) ; if ( is_scalar ( $ commandOptions [ 'cursor' ] ) ) { unset ( $ commandOptions [ 'cursor' ] ) ; } $ timeout = isset ( $ clientOptions [ 'socketTimeoutMS' ] ) ? $ clientOptions [ 'socketTimeoutMS' ] : ( isset ( $ clientOptions [ 'timeout' ] ) ? $ clientOptions [ 'timeout' ] : null ) ; $ riakCollection = $ this -> riakCollection ; $ commandCursor = $ this -> retry ( function ( ) use ( $ riakCollection , $ pipeline , $ commandOptions ) { return $ riakCollection -> aggregateCursor ( $ pipeline , $ commandOptions ) ; } ) ; $ commandCursor = $ this -> wrapCommandCursor ( $ commandCursor ) ; if ( isset ( $ timeout ) ) { $ commandCursor -> timeout ( $ timeout ) ; } return $ commandCursor ; }
|
Executes the aggregate command and returns a RiakCommandCursor .
|
16,192
|
protected function doBatchInsert ( array & $ a , array $ options = array ( ) ) { $ options = isset ( $ options [ 'safe' ] ) ? $ this -> convertWriteConcern ( $ options ) : $ options ; $ options = isset ( $ options [ 'wtimeout' ] ) ? $ this -> convertWriteTimeout ( $ options ) : $ options ; $ options = isset ( $ options [ 'timeout' ] ) ? $ this -> convertSocketTimeout ( $ options ) : $ options ; return $ this -> riakCollection -> batchInsert ( $ a , $ options ) ; }
|
Execute the batchInsert query .
|
16,193
|
protected function doFindAndUpdate ( array $ query , array $ newObj , array $ options ) { list ( $ commandOptions , $ clientOptions ) = isset ( $ options [ 'socketTimeoutMS' ] ) || isset ( $ options [ 'timeout' ] ) ? $ this -> splitCommandAndClientOptions ( $ options ) : array ( $ options , array ( ) ) ; $ command = array ( ) ; $ command [ 'findandmodify' ] = $ this -> riakCollection -> getName ( ) ; $ command [ 'query' ] = ( object ) $ query ; $ command [ 'update' ] = ( object ) $ newObj ; $ command = array_merge ( $ command , $ commandOptions ) ; $ result = $ this -> database -> command ( $ command , $ clientOptions ) ; if ( empty ( $ result [ 'ok' ] ) ) { throw new ResultException ( $ result ) ; } return isset ( $ result [ 'value' ] ) ? $ result [ 'value' ] : null ; }
|
Execute the findAndModify command with the update option .
|
16,194
|
protected function doSave ( array & $ a , array $ options ) { $ options = isset ( $ options [ 'safe' ] ) ? $ this -> convertWriteConcern ( $ options ) : $ options ; $ options = isset ( $ options [ 'wtimeout' ] ) ? $ this -> convertWriteTimeout ( $ options ) : $ options ; $ options = isset ( $ options [ 'timeout' ] ) ? $ this -> convertSocketTimeout ( $ options ) : $ options ; return $ this -> riakCollection -> save ( $ a , $ options ) ; }
|
Execute the save query .
|
16,195
|
protected function doUpdate ( array $ query , array $ newObj , array $ options ) { $ options = isset ( $ options [ 'safe' ] ) ? $ this -> convertWriteConcern ( $ options ) : $ options ; $ options = isset ( $ options [ 'wtimeout' ] ) ? $ this -> convertWriteTimeout ( $ options ) : $ options ; $ options = isset ( $ options [ 'timeout' ] ) ? $ this -> convertSocketTimeout ( $ options ) : $ options ; if ( isset ( $ options [ 'multi' ] ) && ! isset ( $ options [ 'multiple' ] ) ) { $ options [ 'multiple' ] = $ options [ 'multi' ] ; unset ( $ options [ 'multi' ] ) ; } return $ this -> riakCollection -> update ( $ query , $ newObj , $ options ) ; }
|
Execute the update query .
|
16,196
|
protected function wrapCursor ( \ RiakCursor $ cursor , $ query , $ fields ) { return new Cursor ( $ this , $ cursor , $ query , $ fields , $ this -> numRetries ) ; }
|
Wraps a RiakCursor instance with a Cursor .
|
16,197
|
public function isRendered ( ) { $ hasChildren = 0 < count ( $ this -> children ) ; if ( true === $ this -> rendered || ! $ hasChildren ) { return $ this -> rendered ; } if ( $ hasChildren ) { foreach ( $ this -> children as $ child ) { if ( ! $ child -> isRendered ( ) ) { return false ; } } return $ this -> rendered = true ; } return false ; }
|
Returns whether the view was already rendered .
|
16,198
|
public function getParam ( $ name , $ default = null ) { switch ( $ name ) { case 'processor' : return $ this -> getProcessor ( ) ; case 'message' : return $ this -> getMessage ( ) ; case 'result' : return $ this -> getResult ( ) ; default : return parent :: getParam ( $ name , $ default ) ; } }
|
Get event parameter
|
16,199
|
public function getParams ( ) { $ params = parent :: getParams ( ) ; $ params [ 'processor' ] = $ this -> getProcessor ( ) ; $ params [ 'message' ] = $ this -> getMessage ( ) ; $ params [ 'result' ] = $ this -> getResult ( ) ; return $ params ; }
|
Get all event parameters
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.