idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
4,500
public static function getMinuteTimestamp ( $ now = null ) { $ now = $ now === null ? time ( ) : $ now ; $ diff = $ now % 60 ; return $ now - $ diff ; }
get the timestamp at current minute start
4,501
final public static function exec ( string $ cmd , array $ args = [ ] ) { foreach ( $ args as $ key => $ val ) $ args [ $ key ] = escapeshellarg ( $ val ) ; $ cmd = vsprintf ( $ cmd , $ args ) ; exec ( $ cmd , $ output , $ retcode ) ; if ( $ retcode !== 0 ) return false ; return $ output ; }
Execute arbitrary shell commands . Use with care .
4,502
final public static function get_mimetype ( string $ fname , string $ path_to_file = null ) { if ( null === $ mime = self :: _mime_extension ( $ fname ) ) return self :: _mime_magic ( $ fname , $ path_to_file ) ; return $ mime ; }
Find a mime type .
4,503
private static function _mime_extension ( string $ fname ) { $ pinfo = pathinfo ( $ fname ) ; if ( ! isset ( $ pinfo [ 'extension' ] ) ) return null ; switch ( strtolower ( $ pinfo [ 'extension' ] ) ) { case 'css' : return 'text/css' ; case 'js' : return 'application/javascript' ; case 'json' : return 'application/json...
Get MIME by extension .
4,504
private static function _mime_magic ( string $ fname , string $ path_to_file = null ) { if ( function_exists ( 'mime_content_type' ) && ( $ mime = @ mime_content_type ( $ fname ) ) && $ mime != 'application/octet-stream' ) return $ mime ; if ( $ path_to_file && is_executable ( $ path_to_file ) ) { $ bin = $ path_to_fil...
Get MIME type with mime_content_type or file .
4,505
public static function http_client ( array $ kwargs ) { $ url = $ method = null ; $ headers = $ get = $ post = $ custom_opts = [ ] ; $ expect_json = false ; extract ( self :: extract_kwargs ( $ kwargs , [ 'url' => null , 'method' => 'GET' , 'headers' => [ ] , 'get' => [ ] , 'post' => [ ] , 'custom_opts' => [ ] , 'expec...
cURL - based HTTP client .
4,506
final public static function check_dict ( array $ array , array $ keys , bool $ trim = false ) { $ checked = [ ] ; foreach ( $ keys as $ key ) { if ( ! isset ( $ array [ $ key ] ) ) return false ; $ val = $ array [ $ key ] ; if ( $ trim ) { if ( ! is_string ( $ val ) ) return false ; $ val = trim ( $ val ) ; if ( ! $ v...
Check if a dict contains all necessary keys .
4,507
final public static function check_idict ( array $ array , array $ keys , bool $ trim = false ) { if ( false === $ array = self :: check_dict ( $ array , $ keys , $ trim ) ) return false ; foreach ( $ array as $ val ) { if ( ! is_numeric ( $ val ) && ! is_string ( $ val ) ) return false ; } return $ array ; }
Check if a dict contains all necessary keys with elements being immutables i . e . numeric or string .
4,508
final public static function extract_kwargs ( array $ input_array , array $ init_array ) { foreach ( array_keys ( $ init_array ) as $ key ) { if ( isset ( $ input_array [ $ key ] ) ) $ init_array [ $ key ] = $ input_array [ $ key ] ; } return $ init_array ; }
Initiate a kwargs array for safe extraction .
4,509
public static function isValid ( $ visibility ) { switch ( $ visibility ) { case Visibility :: TYPE_PRIVATE : case Visibility :: TYPE_PROTECTED : case Visibility :: TYPE_PUBLIC : return true ; } throw new \ InvalidArgumentException ( 'The ' . $ visibility . ' is not allowed' ) ; }
Validate visiblity .
4,510
public function render ( ) { if ( ! $ this -> _enableXDebugOverlay ) { ini_set ( 'xdebug.overload_var_dump' , 'off' ) ; } $ debuggerCount = count ( $ this -> _debuggers ) ; $ this -> setName ( str_replace ( '{count}' , '{' . $ debuggerCount . '}' , self :: NAME ) ) ; parent :: render ( ) ; }
Renders the panel HTML .
4,511
public function generateEntityCodeAction ( $ id = null ) { $ request = $ this -> getRequest ( ) ; $ id = $ request -> get ( $ this -> admin -> getIdParameter ( ) ) ; if ( $ id ) { $ subject = $ this -> admin -> getObject ( $ id ) ; if ( ! $ subject ) { $ error = sprintf ( 'unable to find the object with id : %s' , $ id...
Generate Entity Code action .
4,512
protected function printPendingVersion ( Version $ version , $ style ) { $ id = $ version -> getId ( ) ; $ reflectionClass = new \ ReflectionClass ( $ version -> getMigration ( ) ) ; $ absolutePath = $ reflectionClass -> getFileName ( ) ; $ fileName = $ absolutePath ? $ this -> getRelativePath ( getcwd ( ) , $ absolute...
Formats and prints a pending version with the given style .
4,513
public function setStyle ( $ style ) { $ dir = ForumEnv :: get ( 'WEB_ROOT' ) . 'themes/' . $ style . '/' ; if ( ! is_dir ( $ dir ) ) { throw new RunBBException ( 'The style ' . $ style . ' doesn\'t exist' ) ; } if ( is_file ( $ dir . 'bootstrap.php' ) ) { $ vars = include_once $ dir . 'bootstrap.php' ; if ( ! is_array...
Initialise style load assets for given style
4,514
public function dumpAction ( ) { return $ this -> newActionMatcher ( ) -> thenExecute ( function ( $ action ) { echo "Action '" . $ action -> getName ( ) . "' : " . var_export ( $ action -> getProperties ( ) , true ) . "\n" ; } ) ; }
Used for debug purposes mainly
4,515
public function upload ( FileRequest $ request ) { $ crudeName = $ request -> input ( 'crudeName' ) ; $ crude = CrudeInstance :: get ( $ crudeName ) ; $ files = $ request -> file ( ) [ 'file' ] ; $ id = $ request -> input ( 'modelId' ) ; $ errors = [ ] ; if ( $ crude instanceof \ JanDolata \ CrudeCRUD \ Engine \ Interf...
Handle files upload file on model is a helper field
4,516
public function downloadAll ( $ crudeName = null , $ id = null ) { if ( ! $ crudeName || ! $ id ) return redirect ( ) -> back ( ) ; $ crude = CrudeInstance :: get ( $ crudeName ) ; if ( ! $ crude ) return redirect ( ) -> back ( ) ; $ model = $ crude -> getModel ( ) -> find ( $ id ) ; if ( ! $ model ) return redirect ( ...
Download all files for model
4,517
public function getNamespace ( ) { if ( ! isset ( $ this -> namespace ) ) { $ reflectionClass = new \ ReflectionClass ( $ this -> name ) ; $ this -> namespace = $ reflectionClass -> getNamespaceName ( ) ; } return $ this -> namespace ; }
Get namespace of the class
4,518
public function getPropertyInfo ( $ prop ) { if ( ! $ this -> loaded ) { $ this -> load ( ) ; } if ( isset ( $ this -> propertiesInfos [ $ prop ] ) ) { return $ this -> propertiesInfos [ $ prop ] ; } return false ; }
Get property information
4,519
public function getPropertyInfoForField ( $ field ) { if ( ! $ this -> loaded ) { $ this -> load ( ) ; } foreach ( $ this -> propertiesInfos as $ name => $ infos ) { if ( $ infos -> getField ( ) == $ field ) { return $ infos ; } } return false ; }
Get property info corresponding to a field
4,520
public function getPropertyForField ( $ field ) { if ( ! $ this -> loaded ) { $ this -> load ( ) ; } foreach ( $ this -> propertiesInfos as $ name => $ infos ) { if ( $ infos -> getField ( ) == $ field ) { return new \ ReflectionProperty ( $ this -> name , $ name ) ; } } return false ; }
Get ReflectionProperty for a field
4,521
public function setCollection ( $ collection ) { if ( ! $ this -> loaded ) { $ this -> load ( ) ; } $ this -> collectionInfo -> setCollection ( $ collection ) ; return $ this ; }
Set the collection
4,522
private function load ( ) { $ reflectionClass = new \ ReflectionClass ( $ this -> name ) ; $ this -> collectionInfo = new CollectionInfo ( ) ; foreach ( $ this -> reader -> getClassAnnotations ( $ reflectionClass ) as $ annotation ) { $ this -> processClassAnnotation ( $ annotation ) ; } $ properties = $ reflectionClas...
Load all metadata
4,523
private function processClassAnnotation ( $ annotation ) { $ class = get_class ( $ annotation ) ; switch ( $ class ) { case "JPC\MongoDB\ODM\Annotations\Mapping\Document" : $ this -> collectionInfo -> setCollection ( $ annotation -> collectionName ) ; if ( null !== ( $ rep = $ annotation -> repositoryClass ) ) { $ this...
Process class annotation to extract infos
4,524
private function processOptionAnnotation ( \ JPC \ MongoDB \ ODM \ Annotations \ Mapping \ Option $ annotation ) { $ options = [ ] ; if ( isset ( $ annotation -> writeConcern ) ) { $ options [ "writeConcern" ] = $ annotation -> writeConcern -> getWriteConcern ( ) ; } if ( isset ( $ annotation -> readConcern ) ) { $ opt...
Process option annotation
4,525
private function processPropertiesAnnotation ( $ name , $ annotation ) { $ class = get_class ( $ annotation ) ; switch ( $ class ) { case "JPC\MongoDB\ODM\Annotations\Mapping\Id" : $ this -> propertiesInfos [ $ name ] -> setField ( "_id" ) ; $ this -> idGenerator = $ annotation -> generator ; break ; case "JPC\MongoDB\...
Process property annotation
4,526
private function checkCollectionCreationOptions ( \ JPC \ MongoDB \ ODM \ Annotations \ Mapping \ Document $ annotation ) { $ options = [ ] ; if ( $ annotation -> capped ) { $ options [ "capped" ] = true ; $ options [ "size" ] = $ annotation -> size ; if ( $ annotation -> max != false ) { $ options [ "max" ] = $ annota...
Check and set collection creation options
4,527
public static function applyCallback ( callable $ callback , NodeInterface $ root , $ targetClass = ChildNodeInterface :: class ) { $ processed = [ ] ; $ f = function ( ChildNodeInterface $ targetNode ) use ( $ callback , $ targetClass , & $ f , & $ processed ) { if ( in_array ( $ targetNode , $ processed , true ) ) { ...
Applies callback to root node if it s existing and further descendant nodes directly after adding to tree .
4,528
public function show ( $ posts , Request $ request ) { $ file = $ posts ; $ markdown = $ this -> pagekit -> markdown ( $ file ) ; $ view = "page::missing-page" ; if ( $ request -> has ( 'page' ) ) : $ markdown = $ this -> pagekit -> markdown ( $ request -> page , $ posts ) ; endif ; if ( ! empty ( $ markdown ) ) : $ vi...
Show a specific page params
4,529
public function getCronjobs ( ) { if ( ! $ this -> cronjobs ) { $ cronjobs = array ( ) ; $ results = $ this -> serviceLocator -> get ( 'Application' ) -> getEventManager ( ) -> trigger ( __FUNCTION__ , $ this , array ( 'cronjobs' => $ cronjobs ) ) ; if ( $ results ) { foreach ( $ results as $ key => $ cron ) { foreach ...
trigger an event and fetch crons Return array
4,530
public function schedule ( ) { $ em = $ this -> getEm ( ) ; $ pending = $ this -> getPending ( ) ; $ exists = array ( ) ; foreach ( $ pending as $ job ) { $ identifier = $ job -> getCode ( ) ; $ identifier .= $ job -> getScheduleTime ( ) -> getTimeStamp ( ) ; $ exists [ $ identifier ] = true ; } $ scheduleAhead = $ thi...
schedule cron jobs
4,531
public function resolve ( $ value , & $ resolutionType ) { if ( is_array ( $ value ) ) { $ value = $ value [ 0 ] ; } if ( is_string ( $ value ) ) { if ( strpos ( $ value , '|' ) !== false ) { $ resolutionType = ResolveAdaptorInterface :: TYPE_PIPELINE ; return $ this -> resolveMiddlewarePipeline ( $ value ) ; } elseif ...
Attempt to convert a provided value into a callable .
4,532
protected function resolveMiddlewarePipeline ( $ value ) { $ value = strstr ( $ value , '|' , true ) ; $ instantiator = $ this -> instantiator ; $ middleware = $ instantiator ( \ Weave \ Middleware \ Middleware :: class ) ; return function ( Request $ request , $ response = null ) use ( $ middleware , $ value ) { retur...
Resolve the provided value to a named middleware chain .
4,533
protected function resolveInstanceMethod ( $ value ) { $ callable = explode ( '->' , $ value ) ; $ instantiator = $ this -> instantiator ; $ callable [ 0 ] = $ instantiator ( $ callable [ 0 ] ) ; return function ( ... $ params ) use ( $ callable ) { return call_user_func_array ( $ callable , $ params ) ; } ; }
Resolve the provided value to an instancelass method call .
4,534
private function processData ( array $ data ) : void { foreach ( $ data [ 'formatters' ] as $ locale => $ f ) { if ( ! isset ( $ this -> formatters [ $ locale ] ) ) { $ this -> formatters [ $ locale ] = array ( ) ; } foreach ( $ f as $ formatter => $ d ) { $ calendar = \ IntlDateFormatter :: GREGORIAN ; if ( isset ( $ ...
Processes the resource file data
4,535
public function getFormatter ( string $ formatter , ? string $ locale = null ) : \ IntlDateFormatter { if ( $ locale === null ) { $ locale = $ this -> locale ; } if ( ! isset ( $ this -> formatters [ $ locale ] ) ) { throw new \ InvalidArgumentException ( 'Locale data not found.' ) ; } if ( ! isset ( $ this -> formatte...
Returns a IntlDateFormatter object
4,536
public function signXML ( $ data ) { $ xml = new DOMDocument ; $ xml -> preserveWhiteSpace = false ; $ xml -> loadXML ( $ data ) ; $ sig = new DOMDocument ; $ sig -> preserveWhiteSpace = false ; $ sig -> loadXML ( '<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"> <SignedInfo> <Ca...
Sign an XML request
4,537
public function generateDigest ( DOMDocument $ xml ) { $ xml = $ xml -> cloneNode ( true ) ; foreach ( $ this -> getXPath ( $ xml ) -> query ( 'ds:Signature' ) as $ node ) { $ node -> parentNode -> removeChild ( $ node ) ; } $ message = $ this -> c14n ( $ xml ) ; return base64_encode ( hash ( 'sha256' , $ message , tru...
Generate sha256 digest of xml
4,538
public function generateSignature ( DOMNode $ xml ) { $ message = $ this -> c14n ( $ xml ) ; $ key = openssl_get_privatekey ( 'file://' . $ this -> getPrivateKeyPath ( ) , $ this -> getPrivateKeyPassphrase ( ) ) ; if ( $ key && openssl_sign ( $ message , $ signature , $ key , OPENSSL_ALGO_SHA256 ) ) { openssl_free_key ...
Generate RSA signature of SignedInfo element
4,539
protected function getProcessingTypesForClient ( array $ processingTypes = null ) { if ( is_null ( $ processingTypes ) ) { $ processingTypes = $ this -> systemConfig -> getAllAvailableProcessingTypes ( ) ; } return array_map ( function ( $ processingTypeClass ) { return $ this -> prepareProcessingType ( $ processingTyp...
Loads available DataTypes from system config and converts some to cient format
4,540
protected function getPreparedCssContent ( ) { if ( $ this -> preparedContent === null ) { $ this -> preparedContent = Placeholder :: replaceStringsAndComments ( $ this -> getCssContent ( ) ) ; $ this -> preparedContent = preg_replace ( '/^([^\r\n]+)(_COMMENT_[a-f0-9]{32}_)([\r\n\t\f]+)/m' , "\\2\n\\1\\3" , $ this -> p...
Gets a prepared version of the CSS content for parsing .
4,541
protected function getCssResource ( ) { $ handle = fopen ( "php://memory" , "rw" ) ; fputs ( $ handle , $ this -> getPreparedCssContent ( ) ) ; rewind ( $ handle ) ; return $ handle ; }
Gets the CSS content as resource .
4,542
public function serialize ( ) { return serialize ( ( object ) [ 'classname' => $ this -> classname , 'type' => $ this -> type , 'service' => $ this -> service , 'parameters' => $ this -> parameters , 'request' => $ this -> request , 'query' => $ this -> query ] ) ; }
Return the serialized data
4,543
public function unserialize ( $ data ) { $ parts = unserialize ( $ data ) ; $ this -> classname = $ parts -> classname ; $ this -> type = $ parts -> type ; $ this -> service = $ parts -> service ; $ this -> parameters = $ parts -> parameters ; $ this -> request = $ parts -> request ; $ this -> query = $ parts -> query ...
Return the unserialized object
4,544
public static function hex ( string $ name = null ) { if ( empty ( $ name ) ) { return static :: $ hexmap ; } return static :: $ hexmap [ $ name ] ?? false ; }
Returns the hexadecimal CSS color given the canonical name .
4,545
public function generate ( $ outputPath ) { $ this -> process ( ) ; $ baseDir = dirname ( $ outputPath ) ; if ( ! is_dir ( $ baseDir ) ) { mkdir ( $ baseDir , 700 , true ) ; } return ( bool ) file_put_contents ( $ outputPath , $ this -> getContent ( ) ) ; }
save generated file to path returns true if file was successfully created false otherwise
4,546
protected function formatValue ( $ value ) { if ( is_array ( $ value ) ) { return Formatter :: formatArray ( $ value ) ; } return Formatter :: formatScalar ( $ value ) ; }
Format a value before processing .
4,547
public function hasArgument ( string $ name ) : bool { $ this -> parsePathArguments ( ) ; return isset ( $ this -> arguments [ $ name ] ) ; }
checks if path contains argument with given name
4,548
public function readArgument ( string $ name ) : ValueReader { $ this -> parsePathArguments ( ) ; if ( isset ( $ this -> arguments [ $ name ] ) ) { return ValueReader :: forValue ( $ this -> arguments [ $ name ] ) ; } return ValueReader :: forValue ( null ) ; }
returns argument with given name or default if not set
4,549
private function parsePathArguments ( ) { if ( null !== $ this -> arguments ) { return ; } $ arguments = [ ] ; preg_match ( '/^' . self :: pattern ( $ this -> configuredPath ) . '/' , $ this -> calledPath , $ arguments ) ; array_shift ( $ arguments ) ; $ names = [ ] ; $ this -> arguments = [ ] ; preg_match_all ( '/[{][...
parses path arguments from called path
4,550
public function remaining ( string $ default = null ) { $ matches = [ ] ; preg_match ( '/(' . self :: pattern ( $ this -> configuredPath ) . ')([^?]*)?/' , $ this -> calledPath , $ matches ) ; $ last = count ( $ matches ) - 1 ; if ( 2 > $ last ) { return $ default ; } if ( isset ( $ matches [ $ last ] ) && ! empty ( $ ...
returns remaining path that was not matched by original path
4,551
public function getTemplate ( $ entityType ) { $ params = [ 'fields' => 'attributes.title' , 'limit' => 1 , ] ; $ definition = $ this -> search ( 'EntityType' , [ 'title' => $ entityType ] , $ params ) ; return array_fill_keys ( array_merge ( [ '_id' ] , array_column ( $ definition [ 0 ] [ 'attributes' ] , 'title' ) ) ...
Returns an array that has all the fields according to the definition in Communibase .
4,552
public function getById ( $ entityType , $ id , array $ params = [ ] , $ version = null ) { if ( empty ( $ id ) ) { throw new Exception ( 'Id is empty' ) ; } if ( ! static :: isIdValid ( $ id ) ) { throw new Exception ( 'Id is invalid, please use a correctly formatted id' ) ; } return ( $ version === null ) ? $ this ->...
Get a single Entity by its id
4,553
public function getByRef ( array $ ref , array $ parentEntity = [ ] ) { $ document = $ parentEntity ; if ( strpos ( $ ref [ 'rootDocumentEntityType' ] , 'parent' ) === false ) { if ( empty ( $ document [ '_id' ] ) || $ document [ '_id' ] !== $ ref [ 'rootDocumentId' ] ) { $ document = $ this -> getById ( $ ref [ 'rootD...
Get a single Entity by a ref - string
4,554
public function getByIds ( $ entityType , array $ ids , array $ params = [ ] ) { $ validIds = array_values ( array_unique ( array_filter ( $ ids , [ __CLASS__ , 'isIdValid' ] ) ) ) ; if ( count ( $ validIds ) === 0 ) { return [ ] ; } $ doSortByIds = empty ( $ params [ 'sort' ] ) ; $ results = $ this -> search ( $ entit...
Get an array of entities by their ids
4,555
public function getIds ( $ entityType , array $ selector = [ ] , array $ params = [ ] ) { $ params [ 'fields' ] = '_id' ; return array_column ( $ this -> search ( $ entityType , $ selector , $ params ) , '_id' ) ; }
Get result entityIds of a certain search
4,556
public function getId ( $ entityType , array $ selector = [ ] ) { $ params = [ 'limit' => 1 ] ; $ ids = ( array ) $ this -> getIds ( $ entityType , $ selector , $ params ) ; return array_shift ( $ ids ) ; }
Get the id of an entity based on a search
4,557
public function update ( $ entityType , array $ properties ) { if ( empty ( $ properties [ '_id' ] ) ) { return $ this -> doPost ( $ entityType . '.json/crud/' , [ ] , $ properties ) ; } return $ this -> doPut ( $ entityType . '.json/crud/' . $ properties [ '_id' ] , [ ] , $ properties ) ; }
This will save an entity in Communibase . When a _id - field is found this entity will be updated
4,558
public function finalize ( $ entityType , $ id ) { if ( $ entityType !== 'Invoice' ) { throw new Exception ( 'Cannot call finalize on ' . $ entityType ) ; } return $ this -> doPost ( $ entityType . '.json/finalize/' . $ id ) ; }
Finalize an invoice by adding an invoiceNumber to it . Besides invoice items will receive a generalLedgerAccountNumber . This number will be unique and sequential within the daybook of the invoice .
4,559
protected function doGet ( $ path , array $ params = null , array $ data = null ) { return $ this -> getResult ( 'GET' , $ path , $ params , $ data ) ; }
Perform the actual GET
4,560
protected function doPost ( $ path , array $ params = null , array $ data = null ) { return $ this -> getResult ( 'POST' , $ path , $ params , $ data ) ; }
Perform the actual POST
4,561
protected function doPut ( $ path , array $ params = null , array $ data = null ) { return $ this -> getResult ( 'PUT' , $ path , $ params , $ data ) ; }
Perform the actual PUT
4,562
protected function doDelete ( $ path , array $ params = null , array $ data = null ) { return $ this -> getResult ( 'DELETE' , $ path , $ params , $ data ) ; }
Perform the actual DELETE
4,563
private function parseResult ( $ response , $ httpCode ) { $ result = json_decode ( $ response , true ) ; if ( is_array ( $ result ) ) { return $ result ; } throw new Exception ( '"' . $ this -> getLastJsonError ( ) . '" in ' . $ response , $ httpCode ) ; }
Parse the Communibase result and if necessary throw an exception
4,564
private function getLastJsonError ( ) { static $ messages = [ JSON_ERROR_DEPTH => 'Maximum stack depth exceeded' , JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch' , JSON_ERROR_CTRL_CHAR => 'Unexpected control character found' , JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON' , JSON_ERROR_UTF8 => 'Mal...
Error message based on the most recent JSON error .
4,565
private function call ( $ method , array $ arguments ) { try { if ( isset ( $ this -> extraHeaders [ 'host' ] ) ) { $ arguments [ 1 ] [ 'headers' ] [ 'Host' ] = $ this -> extraHeaders [ 'host' ] ; } if ( $ this -> logger ) { $ this -> logger -> startQuery ( $ method . ' ' . reset ( $ arguments ) , $ arguments ) ; } $ r...
Perform the actual call to Communibase
4,566
protected function run ( Request $ request ) { $ handler = $ request -> getAttribute ( 'dispatch.handler' , false ) ; if ( $ handler === false ) { return $ this -> chain ( $ request ) ; } $ request = $ request -> withAttribute ( 'dispatch.handler' , $ this -> resolver -> shift ( $ handler ) ) ; $ dispatchable = $ this ...
Handle a dispatch .
4,567
public function sort ( ) { if ( $ this -> modules ) { $ modules = [ ] ; $ sorter = new StringSort ( ) ; foreach ( $ this -> modules as $ slug => $ module ) { $ sorter -> add ( $ slug , array_intersect ( array_keys ( $ module -> getAttribute ( 'require' ) ) , array_keys ( $ this -> modules ) ) ) ; } foreach ( $ sorter -...
Sort modules by their dependencies .
4,568
public function register ( ) { foreach ( $ this -> modules as $ module ) { if ( $ aggregator = $ module -> getAttribute ( 'aggregator' ) ) { $ this -> container -> register ( $ aggregator ) ; } } return $ this ; }
Register modules with service container .
4,569
private function getRangeData ( ShippingMethodCost $ cost ) { return [ 'min' => $ cost -> getRangeFrom ( ) , 'max' => $ cost -> getRangeTo ( ) , 'price' => $ cost -> getCost ( ) -> getGrossAmount ( ) , ] ; }
Returns costs data as an array
4,570
public function load ( ServiceContainer $ container , array $ params ) { $ container -> define ( 'ecomdev.phpspec.magento_di_adapter.vfs' , $ this -> vfsFactory ( ) ) ; $ container -> define ( 'ecomdev.phpspec.magento_di_adapter.code_generator.io' , $ this -> ioFactory ( ) ) ; $ container -> define ( 'ecomdev.phpspec.m...
Load collaborator into PHPSpec ServiceContainer
4,571
public function parameterValidatorFactory ( ) { return function ( ServiceContainer $ container ) { $ parameterValidator = new ParameterValidator ( $ container -> get ( 'ecomdev.phpspec.magento_di_adapter.code_generator.io' ) , $ container -> get ( 'ecomdev.phpspec.magento_di_adapter.code_generator.defined_classes' ) , ...
Factory for instantiation of parameter validator
4,572
public function fromResponse ( array $ data ) { $ map = array ( 'id' => 'setId' , 'start' => 'setStart' , 'end' => 'setEnd' , 'hash' => 'setHash' , 'parameters' => 'setParameters' , 'created_at' => 'setCreatedAt' , 'progress' => 'setProgress' , 'status' => 'setStatus' , 'feeds' => 'setFeeds' , 'sample' => 'setSample' ,...
Hydrates this preview from an array of API responses
4,573
public function create ( ) { $ params = array ( 'start' => $ this -> getStart ( ) , 'hash' => $ this -> getHash ( ) , 'parameters' => implode ( ',' , $ this -> getParameters ( ) ) ) ; if ( is_int ( $ this -> end ) ) { $ params [ 'end' ] = $ this -> getEnd ( ) ; } $ this -> fromResponse ( $ this -> getUser ( ) -> post (...
Create the preview represented by the parameters in this object
4,574
public static function listHistorics ( $ user , $ page = 1 , $ per_page = 20 ) { try { $ res = $ user -> post ( 'historics/get' , array ( 'page' => $ page , 'max' => $ page , ) ) ; $ retval = array ( 'count' => $ res [ 'count' ] , 'historics' => array ( ) ) ; foreach ( $ res [ 'data' ] as $ historic ) { $ retval [ 'his...
List Historics queries .
4,575
public function reloadData ( ) { if ( $ this -> _deleted ) { throw new DataSift_Exception_InvalidData ( 'Cannot reload the data for a deleted Historic.' ) ; } if ( $ this -> _playback_id === false ) { throw new DataSift_Exception_InvalidData ( 'Cannot reload the data for a Historic with no playback ID.' ) ; } try { $ t...
Reload the data for this object from the API .
4,576
protected function initFromArray ( $ data ) { if ( ! isset ( $ data [ 'id' ] ) ) { throw new DataSift_Exception_APIError ( 'No playback ID in the response' ) ; } if ( $ data [ 'id' ] != $ this -> _playback_id ) { throw new DataSift_Exception_APIError ( 'Incorrect playback ID in the response' ) ; } if ( ! isset ( $ data...
Initialise this object from the data in the given array .
4,577
public function prepare ( ) { if ( $ this -> _deleted ) { throw new DataSift_Exception_InvalidData ( 'Cannot prepare a deleted Historic.' ) ; } if ( $ this -> _playback_id !== false ) { throw new DataSift_Exception_InvalidData ( 'This historic query has already been prepared.' ) ; } try { $ res = $ this -> _user -> pos...
Call the DataSift API to prepare this historic query .
4,578
public function stop ( ) { if ( $ this -> _deleted ) { throw new DataSift_Exception_InvalidData ( 'Cannot stop a deleted Historic.' ) ; } if ( $ this -> _playback_id === false || strlen ( $ this -> _playback_id ) == 0 ) { throw new DataSift_Exception_InvalidData ( 'Cannot stop a historic query that hasn\'t been prepare...
Stop this historic query .
4,579
public function pause ( $ reason = false ) { if ( $ this -> _deleted ) { throw new DataSift_Exception_InvalidData ( 'Cannot pause a deleted Historic.' ) ; } if ( $ this -> _playback_id === false || strlen ( $ this -> _playback_id ) == 0 ) { throw new DataSift_Exception_InvalidData ( 'Cannot pause a historic query that ...
Pause this historic query .
4,580
final public function internalSetParent ( ParentNodeInterface $ parent ) { $ this -> emit ( 'parent.change' , [ $ parent , $ this ] ) ; $ this -> parentNode = $ parent ; }
Attaches component to registry .
4,581
public function create ( $ table , $ data ) { $ keys = array_keys ( $ data ) ; $ values = ':' . implode ( ',:' , $ keys ) ; $ keys = implode ( ',' , $ keys ) ; return $ this -> query ( $ this -> set ( "INSERT INTO {$table} ({$keys}) VALUES({$values})" , $ data ) ) ; }
Perform an INSERT statement .
4,582
public function delete ( $ table , $ data , $ conjunction = 'AND' ) { $ keys = array_keys ( $ data ) ; $ pairs = Array ( ) ; foreach ( $ keys as $ key ) { $ pairs [ ] = "{$key}=:{$key}" ; } $ pairs = implode ( " {$conjunction} " , $ pairs ) ; return $ this -> query ( $ this -> set ( "DELETE FROM {$table} WHERE {$pairs}...
Perform a DELETE statement .
4,583
public function update ( $ table , $ data , $ where , $ conjunction = 'AND' ) { $ values = array_merge ( array_values ( $ data ) , array_values ( $ where ) ) ; $ keys = array_keys ( $ data ) ; $ pairs = Array ( ) ; foreach ( $ keys as $ key ) { $ pairs [ ] = "{$key}=?" ; } $ pairs = implode ( ',' , $ pairs ) ; $ keys =...
Perform an UPDATE statement .
4,584
public function select ( $ table , $ select , $ where , $ conjunction = 'AND' ) { $ keys = array_keys ( $ where ) ; $ pairs = Array ( ) ; foreach ( $ keys as $ key ) { $ pairs [ ] = "{$key}=:{$key}" ; } $ pairs = implode ( " {$conjunction} " , $ pairs ) ; if ( is_array ( $ select ) ) { $ select = implode ( ',' , $ sele...
Perform a SELECT statement .
4,585
public function set ( $ q , $ args ) { if ( is_array ( $ args ) && isset ( $ args [ 'raw' ] ) ) { $ q = implode ( $ args [ 'raw' ] , explode ( '?' , $ q , 2 ) ) ; ; } else if ( is_array ( $ args ) ) { $ first = array_keys ( $ args ) ; $ first = array_shift ( $ first ) ; if ( ! is_numeric ( $ first ) ) { return $ this -...
Bind passed variables into a query string and do proper type checking and escaping before binding .
4,586
private function setQuestionMarkPlaceHolders ( $ q , $ args ) { foreach ( $ args as $ k => $ a ) { if ( is_array ( $ a ) && isset ( $ a [ 'raw' ] ) ) { $ args [ $ k ] = $ a [ 'raw' ] ; } else { $ args [ $ k ] = $ this -> prepareType ( $ a ) ; } } $ positions = Array ( ) ; $ p = - 1 ; while ( ( $ p = strpos ( $ q , '?' ...
Set ? mark value placeholders with the values passed in args in the order they are set in the query and the args .
4,587
private function prepareType ( $ arg ) { if ( ( $ arg === null || $ arg == 'null' ) && $ arg !== 0 ) { return 'NULL' ; } if ( ! is_numeric ( $ arg ) ) { return $ this -> quote ( $ arg ) ; } return $ arg ; }
Determine the type of variable being bound into the query either a String or Numeric .
4,588
public static function create ( $ url , $ pipelineId , $ apiToken , $ password ) { $ baseUrl = $ url . '/rest_services/v1/' . $ pipelineId ; $ httpClient = new CurlHttpClient ( ) ; $ httpClient -> setUserCredentials ( $ apiToken , $ password ) ; $ dateTimeFormat = Defaults :: DATE_FORMAT ; $ repoFactory = new RestRepos...
Creates a PipelinerClient object with sensible default configuration . Will perform a HTTP request to fetch the existing entity types for the pipeline .
4,589
public function getRepository ( $ entityName ) { if ( $ entityName instanceof Entity ) { $ entityName = $ entityName -> getType ( ) ; } if ( ! isset ( $ this -> repositories [ $ entityName ] ) ) { $ plural = $ this -> getCollectionName ( $ entityName ) ; $ this -> repositories [ $ entityName ] = $ this -> repositoryFac...
Returns a repository for the specified entity .
4,590
public function parse ( \ Twig_Token $ token ) { $ lineno = $ token -> getLine ( ) ; $ nodes [ 'criteria' ] = $ this -> parser -> getExpressionParser ( ) -> parseExpression ( ) ; $ this -> parser -> getStream ( ) -> expect ( 'as' ) ; $ targets = $ this -> parser -> getExpressionParser ( ) -> parseAssignmentExpression (...
Define how our page tag should be parsed .
4,591
private static function initialize ( $ method , $ ssl , $ url , $ headers , $ params , $ userAgent , $ qs , $ raw = false ) { $ ch = curl_init ( ) ; switch ( strtolower ( $ method ) ) { case 'post' : curl_setopt ( $ ch , CURLOPT_POST , true ) ; curl_setopt ( $ ch , CURLOPT_POSTFIELDS , ( $ raw ? $ params : json_encode ...
Initalize the cURL connection .
4,592
protected static function decodeBody ( array $ res ) { $ format = isset ( $ res [ 'headers' ] [ 'x-datasift-format' ] ) ? $ res [ 'headers' ] [ 'x-datasift-format' ] : $ res [ 'headers' ] [ 'content-type' ] ; $ retval = array ( ) ; if ( strtolower ( $ format ) == 'json_new_line' ) { foreach ( explode ( "\n" , $ res [ '...
Decode the JSON response depending on the format .
4,593
private static function parseHTTPResponse ( $ str ) { $ retval = array ( 'headers' => array ( ) , 'body' => '' , ) ; $ lastfield = false ; $ fields = explode ( "\n" , preg_replace ( '/\x0D\x0A[\x09\x20]+/' , ' ' , $ str ) ) ; foreach ( $ fields as $ field ) { if ( strlen ( trim ( $ field ) ) == 0 ) { $ lastfield = ':bo...
Parse an HTTP response . Separates the headers from the body and puts the headers into an associative array .
4,594
public function onKernelRequest ( GetResponseEvent $ event ) { $ this -> errorHandler -> registerErrorHandler ( $ this -> notifier ) ; $ this -> errorHandler -> registerShutdownHandler ( $ this -> notifier ) ; }
Register error handler .
4,595
public function onKernelException ( GetResponseForExceptionEvent $ event ) { if ( $ event -> getException ( ) instanceof HttpException ) { return ; } $ this -> setException ( $ event -> getException ( ) ) ; }
Save exception .
4,596
public function onKernelResponse ( FilterResponseEvent $ event ) { if ( $ this -> getException ( ) ) { $ this -> notifier -> reportException ( $ this -> getException ( ) ) ; $ this -> setException ( null ) ; } }
Wrap exception with additional info .
4,597
public function setTheme ( DataSourceViewInterface $ dataSource , $ theme , array $ vars = [ ] ) { $ this -> themes [ $ dataSource -> getName ( ) ] = ( $ theme instanceof Twig_Template ) ? $ theme : $ this -> environment -> loadTemplate ( $ theme ) ; $ this -> themesVars [ $ dataSource -> getName ( ) ] = $ vars ; }
Set theme for specific DataSource . Theme is nothing more than twig template that contains some or all of blocks required to render DataSource .
4,598
public function setRoute ( DataSourceViewInterface $ dataSource , $ route , array $ additional_parameters = [ ] ) { $ this -> routes [ $ dataSource -> getName ( ) ] = $ route ; $ this -> additional_parameters [ $ dataSource -> getName ( ) ] = $ additional_parameters ; }
Set route and optionally additional parameters for specific DataSource .
4,599
private function resolveMaxResultsOptions ( array $ options , DataSourceViewInterface $ dataSource ) { $ optionsResolver = new OptionsResolver ( ) ; $ optionsResolver -> setDefaults ( [ 'route' => $ this -> getCurrentRoute ( $ dataSource ) , 'active_class' => 'active' , 'additional_parameters' => [ ] , 'results' => [ 5...
Validate and resolve options passed in Twig to datasource_results_per_page_widget