idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
8,800
function contruye_excel ( $ id ) { $ this -> layout = 'excel' ; Configure :: write ( 'debug' , 0 ) ; $ this -> RequestHandler -> setContent ( 'xls' , 'application/vnd.ms-excel' ) ; $ res = $ this -> Query -> findById ( $ id ) ; $ sql = $ res [ 'Query' ] [ 'query' ] ; $ this -> Query -> recursive = - 1 ; $ consulta_ejec...
esto me construye un excel en la vista con el id de la query
8,801
private function db_update ( $ file ) { require $ file ; if ( isset ( $ table ) ) { $ config = wp_parse_args ( $ table , [ 'name' => str_replace ( '.php' , '' , basename ( $ file ) ) , 'version' => false , 'engine' => Engine :: INNODB , 'columns' => false , 'primary_key' => [ ] , 'indexes' => [ ] , 'unique' => [ ] , 'f...
Update db if possible
8,802
private function make_query ( $ config ) { extract ( $ config ) ; if ( empty ( $ columns ) ) { throw new \ Exception ( sprintf ( 'Columns of %s shouldn\'t be empty.' , $ name ) , 500 ) ; } $ column_query = [ ] ; foreach ( $ columns as $ name => $ column ) { $ column_query [ ] = Column :: build_query ( $ name , $ column...
Build create query
8,803
protected function need_update ( $ name , $ version ) { return ! isset ( $ this -> option [ $ name ] ) || ! $ this -> option [ $ name ] || version_compare ( $ this -> option [ $ name ] , $ version , '<' ) ; }
Detect if source version is greater than existing db
8,804
public function setTheme ( $ name ) { $ this -> getResponse ( ) -> setThemeName ( $ name ) ; $ this -> getResponse ( ) -> getTheme ( ) -> setName ( $ name ) ; }
Set the theme name in both the response and the theme objects
8,805
public function setBodyTitle ( $ title ) { $ this -> getResponse ( ) -> getTheme ( ) -> setBodyTitle ( $ title ) ; $ this -> _title = $ title ; }
Set page content title to be themed in the view
8,806
public function addView ( $ view , $ data = null ) { if ( ! is_object ( $ view ) ) $ view = new \ erdiko \ core \ View ( $ view , $ data ) ; if ( $ data != null ) $ view -> setData ( $ data ) ; $ this -> appendContent ( $ view -> toHtml ( ) ) ; }
Add a view from the current theme with the given data
8,807
public function getLayout ( $ layoutName , $ data = null , $ templateRootFolder = null ) { $ layout = new \ erdiko \ core \ Layout ( $ layoutName , $ data , $ this -> getThemeName ( ) ) ; $ layout -> setTitle ( $ this -> getBodyTitle ( ) ) ; if ( $ templateRootFolder != null ) { $ layout -> setViewRootFolder ( $ templa...
Load a layout with the given data
8,808
public function setMeta ( $ meta ) { foreach ( $ meta as $ name => $ content ) $ this -> getResponse ( ) -> getTheme ( ) -> addMeta ( $ name , $ content ) ; }
Set multiple meta fields at once
8,809
public function addPhpToJs ( $ key , $ value ) { if ( is_bool ( $ value ) ) { $ value = $ value ? "true" : "false" ; } elseif ( is_string ( $ value ) ) { $ value = "\"$value\"" ; } elseif ( is_array ( $ value ) ) { $ value = json_encode ( $ value ) ; } elseif ( is_object ( $ value ) && method_exists ( $ value , "toArra...
Add phpToJs variable to be set on the current page
8,810
public function setShipping ( \ Gpupo \ CommonSchema \ ORM \ Entity \ Trading \ Order \ Shipping \ Shipping $ shipping = null ) { $ this -> shipping = $ shipping ; return $ this ; }
Set shipping .
8,811
public function groups ( ) { $ a = & $ this -> class_cfg [ 'arch' ] ; $ t = & $ this -> class_cfg [ 'tables' ] ; $ id = $ this -> db -> cfn ( $ a [ 'groups' ] [ 'id' ] , $ t [ 'groups' ] , 1 ) ; $ group = $ this -> db -> cfn ( $ a [ 'groups' ] [ 'group' ] , $ t [ 'groups' ] , 1 ) ; $ id_group = $ this -> db -> cfn ( $ ...
Returns all the users groups - with or without admin
8,812
public function call ( $ method , Array $ params = [ ] ) { $ params = $ this -> mergeParams ( $ method , $ params ) ; try { $ result = $ this -> soapClient -> __soapCall ( $ method , $ params ) ; } catch ( SoapFault $ fault ) { throw $ fault ; } return $ result ; }
Prepare and issue a call
8,813
protected function mergeParams ( $ method , Array $ params = [ ] ) { $ mergedParams = array_merge ( $ this -> defaultParams , $ params ) ; $ newParams = [ $ method => $ mergedParams ] ; return $ newParams ; }
Default way to merge params
8,814
protected function deleteExtraRecords ( ) { try { $ limit = ( int ) ( $ this -> limitMax ) ; } catch ( \ Exception $ ex ) { Yii :: error ( $ ex -> getMessage ( ) , __METHOD__ ) ; return 0 ; } $ host = $ this -> host ; $ count = static :: find ( ) -> createdBy ( $ host ) -> count ( ) ; Yii :: info ( $ host -> getReadabl...
Delete extra records .
8,815
protected function deleteExpiredRecords ( ) { try { $ limit = ( int ) ( $ this -> limitDuration ) ; } catch ( \ Exception $ ex ) { Yii :: error ( $ ex -> getMessage ( ) , __METHOD__ ) ; return 0 ; } $ count = 0 ; $ host = $ this -> host ; foreach ( static :: find ( ) -> createdBy ( $ host ) -> andWhere ( [ '<=' , $ thi...
Delete expired records .
8,816
public function has_data ( $ idx = null ) { if ( ! \ is_array ( $ this -> data ) ) { return false ; } if ( \ is_null ( $ idx ) ) { return ! empty ( $ this -> data ) ; } $ args = \ func_get_args ( ) ; foreach ( $ args as $ arg ) { if ( ! isset ( $ this -> data [ $ idx ] ) ) { return false ; } } return true ; }
Checks if data exists or if a specific index exists in the data
8,817
protected function _findSource ( ) { $ path = $ this -> _manager -> getPath ( ) ; if ( $ path -> isVirtual ( $ this -> _source ) ) { $ path = $ path -> get ( $ this -> _source ) ; $ isStrictMode = $ this -> _manager -> getParams ( ) -> get ( 'strict_mode' , false , 'bool' ) ; if ( $ isStrictMode && ! $ path ) { throw n...
Find source in variants .
8,818
public function createService ( ServiceLocatorInterface $ serviceLocator ) { $ appConfig = $ serviceLocator ; $ config = array_key_exists ( $ appConfig [ 'view_helper_date' ] ) ? $ appConfig [ 'view_helper_date' ] : array ( ) ; if ( array_key_exists ( 'formats' , $ config ) ) { $ this -> addFormats ( $ config [ 'format...
Create and configure instance
8,819
public function addFormats ( array $ formats ) { foreach ( $ formats as $ name => $ format ) { $ this -> formats [ $ name ] = $ format ; } }
Add datetime formats
8,820
protected function options ( ) { $ areas = app ( AreaManager :: class ) -> getAreas ( ) ; $ options = [ ] ; foreach ( $ areas as $ area ) { array_set ( $ options , $ area -> getId ( ) , $ area -> getLabel ( ) ) ; } return $ options ; }
Filter instance dataprovider
8,821
public static function findByKey ( $ array , $ key , $ value ) { foreach ( $ array as $ element ) if ( call_user_func ( array ( $ element , $ key ) ) === $ value ) return $ element ; return null ; }
Finds an array element by comparing a member with the given value .
8,822
public static function sortByKey ( $ _array , $ key ) { $ array = $ _array ; $ result = usort ( $ array , function ( $ a , $ b ) use ( $ key ) { return strcmp ( call_user_func ( array ( $ a , $ key ) ) , call_user_func ( array ( $ b , $ key ) ) ) ; } ) ; if ( ! $ result ) throw new ArrayException ( "sorting by \"$key\"...
Sorts an array in ascending order regarding a member .
8,823
protected function prepareToIndent ( ) { foreach ( $ this -> lines as $ lineNumber => $ line ) { $ this -> lines [ $ lineNumber ] = trim ( $ line ) ; } $ this -> outputLines = $ this -> lines ; }
Pre - process all the lines so they are ready to be indented
8,824
public function createAndExecute ( ) { $ request = $ this -> createRequest ( ) ; $ response = $ this -> api -> execute ( $ request , $ this ) ; $ this -> response = $ response ; return $ response ; }
Create and execute the operation returning the raw response from the server .
8,825
public function dispatchAsync ( \ Amp \ Artax \ Request $ request , callable $ callable ) { return $ this -> api -> executeAsync ( $ request , $ this , $ callable ) ; }
Dispatch the request for this operation and process the response asynchronously . Allows you to modify the request before it is sent .
8,826
public static function getGeneratorMap ( ) { $ generatorMap = array ( ) ; foreach ( self :: getGenerators ( ) as $ generator ) $ generatorMap [ call_user_func ( array ( $ generator , "getKey" ) ) ] = $ generator ; return $ generatorMap ; }
Returns a map from all generator keys to class names .
8,827
public function generateFiles ( ) { if ( $ this -> files === null ) { $ this -> files = array ( ) ; $ this -> tracingLinks = array ( ) ; $ this -> _generateFiles ( ) ; } if ( $ this -> settings -> getOptional ( "logFile" , false ) ) return array_merge ( array ( $ this -> logFile ) , $ this -> files ) ; else return $ th...
Generates the files for all registered artifacts . If the files have already been generated returns the cached files . The generator s log file is included .
8,828
protected function isSelectedFeature ( $ featureName ) { $ isSelected = false ; foreach ( $ this -> selectedArtifacts as $ selectedArtifact ) if ( $ featureName === $ selectedArtifact -> getFeature ( ) -> getName ( ) ) $ isSelected = true ; return $ isSelected ; }
Returns whether a feature s artifact is selected .
8,829
public function createObject ( $ builder , $ parameters = array ( ) ) { if ( is_string ( $ builder ) ) { if ( class_exists ( $ builder ) ) { $ response = $ parameters [ 'response' ] ; $ nextMiddleware = $ parameters [ 'next' ] ; if ( $ response == null ) { throw new InvalidArgumentException ( "'response' parameters mus...
Creates a middleware instance
8,830
public static function get_files ( $ dir , $ including_dirs = false , $ hidden = false , $ extension = null ) { $ dir = self :: clean ( $ dir ) ; clearstatcache ( ) ; if ( $ dir === './' ) { $ dir = '.' ; } if ( is_dir ( $ dir ) && ( ( $ dir === '.' ) || ( ( strpos ( basename ( $ dir ) , '.' ) !== 0 ) || $ hidden ) ) )...
Returns an array of files contained in the given directory . Returns the full path of files .
8,831
public static function delete ( string $ dir , bool $ full = true ) : bool { $ dir = self :: clean ( $ dir ) ; if ( is_dir ( $ dir ) ) { $ files = self :: get_files ( $ dir , 1 , 1 ) ; foreach ( $ files as $ file ) { self :: delete ( $ file ) ; } if ( $ full ) { return rmdir ( $ dir ) ; } return true ; } if ( is_file (...
Deletes the given directory and all its content .
8,832
public static function scan ( string $ dir , string $ type = null , bool $ hidden = false ) : array { $ all = [ ] ; $ dir = self :: clean ( $ dir ) ; $ dirs = self :: get_dirs ( $ dir ) ; if ( \ is_array ( $ dirs ) ) { if ( $ type && ( strpos ( $ type , 'file' ) === 0 ) ) { $ all = self :: get_files ( $ dir , false , $...
Returns an array with all the content of the given directory .
8,833
public static function get_tree ( string $ dir , bool $ only_dir = false , callable $ filter = null , bool $ hidden = false ) : array { $ r = [ ] ; $ dir = self :: clean ( $ dir ) ; $ dirs = self :: get_dirs ( $ dir , $ hidden ) ; if ( \ is_array ( $ dirs ) ) { foreach ( $ dirs as $ d ) { $ x = [ 'name' => $ d , 'type'...
Return an array with the tree of the folder s content .
8,834
public static function create_path ( string $ dir , $ chmod = false ) { if ( ! $ dir || ! \ is_string ( $ dir ) ) { return false ; } clearstatcache ( ) ; if ( ! is_dir ( $ dir ) ) { $ bits = explode ( '/' , $ dir ) ; $ path = empty ( $ bits [ 0 ] ) ? '/' : '' ; foreach ( $ bits as $ i => $ b ) { if ( ! empty ( $ b ) ) ...
Creates a folder with the given path .
8,835
public static function move ( $ orig , $ dest , $ st = '_v' , $ length = 0 ) : bool { if ( file_exists ( $ orig ) && self :: create_path ( \ dirname ( $ dest ) ) ) { if ( file_exists ( $ dest ) ) { if ( $ st === true ) { self :: delete ( $ dest ) ; } else { $ i = 1 ; while ( $ i ) { $ dir = \ dirname ( $ dest ) . '/' ;...
Moves a file or directory to a new location
8,836
public static function copy ( $ src , $ dst ) : bool { if ( is_file ( $ src ) ) { return copy ( $ src , $ dst ) ; } if ( is_dir ( $ src ) && self :: create_path ( $ dst ) ) { $ files = self :: get_files ( $ src ) ; $ dirs = self :: get_dirs ( $ src ) ; foreach ( $ files as $ f ) { copy ( $ f , $ dst . '/' . basename ( ...
Will move the content of the given folder to a new destination . Doesn t move the hidden files .
8,837
public function appendText ( $ value ) { $ text = $ this -> stringify ( $ value ) ; $ this -> message = $ this -> message . $ text ; return $ this ; }
Append the text to the last .
8,838
public function appendSpace ( $ length ) { $ paddingLength = ( int ) $ length ; $ this -> message = $ this -> message . str_pad ( '' , $ paddingLength , ' ' ) ; return $ this ; }
Append the length space .
8,839
public function appendValue ( $ value ) { $ appendValue = $ this -> formatValue ( $ value ) ; $ this -> message = $ this -> message . $ appendValue ; return $ this ; }
Append the value to the last .
8,840
public function appendValues ( array $ values ) { $ appendValues = [ ] ; foreach ( $ values as $ value ) { $ appendValues [ ] = $ this -> formatValue ( $ value ) ; } $ this -> message = $ this -> message . implode ( ', ' , $ appendValues ) ; return $ this ; }
Append the values to the last .
8,841
public function respond ( int $ statusCode = null , array $ headers = [ ] ) : JsonResponse { if ( ! is_null ( $ statusCode ) ) { $ this -> setStatus ( $ statusCode ) ; } $ data = $ this -> toArray ( ) ; $ data = $ this -> includeStatusCode ( $ data ) ; $ data = $ this -> includeSuccessFlag ( $ data ) ; return $ this ->...
Serialize the data and wrap it in a JSON response object .
8,842
public function load ( $ resource , $ type = null ) { $ repository = $ this -> delegatingLoader -> load ( $ resource , $ type ) ; if ( ! $ repository instanceof ConfigRepositoryInterface ) { throw new \ UnexpectedValueException ( 'The loader must return a repository instance' ) ; } return $ repository ; }
Loads a resource like file or inline configuration
8,843
public static function routes ( ) { $ area = area ( ) ; Route :: post ( $ area . '/notifications/notifications' , NotificationController :: class . '@index' ) ; Route :: post ( $ area . '/notifications/widgets/send' , NotificationController :: class . '@send' ) ; }
Widgets routes implementations
8,844
public function render ( ) { app ( 'antares.asset' ) -> container ( 'antares/foundation::application' ) -> add ( 'webpack_forms_basic' , '/webpack/forms_basic.js' , [ 'app_cache' ] ) ; publish ( 'notifications' , [ 'js/notification-widget.js' ] ) ; return view ( 'antares/notifications::widgets.send_notification' , [ 'f...
Renders widget content
8,845
protected function replaceInlineExamples ( DescriptorAbstract $ element ) { $ description = $ element -> getDescription ( ) ; $ matches = array ( ) ; if ( ! $ description || ! preg_match_all ( '/\{@example\s(.+?)\}/' , $ description , $ matches ) || count ( $ matches [ 0 ] ) < 1 ) { return $ description ; } $ matched =...
Replaces the example tags in the description with the contents of the found example .
8,846
protected function processSchema ( array $ tables ) { $ schemaDefinition = array ( ) ; array_walk ( $ tables , create_function ( '&$item,$key' , '$item = $item[0];' ) ) ; $ prefix = ezcDbSchema :: $ options -> tableNamePrefix ; foreach ( $ tables as $ tableName ) { $ tableNameWithoutPrefix = substr ( $ tableName , strl...
Loops over all the table names in the array and extracts schema information .
8,847
protected function lowercase ( array $ source ) { $ result = array ( ) ; foreach ( $ source as $ key => $ value ) $ result [ strtolower ( $ key ) ] = $ value ; return $ result ; }
Lowercase all array keys to conform default Database behaviour
8,848
private function applyAttribs ( Tokens $ tokens , $ index , array $ attribs ) { $ toInsert = [ ] ; foreach ( $ attribs as $ attrib ) { if ( null !== $ attrib && '' !== $ attrib -> getContent ( ) ) { $ toInsert [ ] = $ attrib ; $ toInsert [ ] = new Token ( [ T_WHITESPACE , ' ' ] ) ; } } if ( ! empty ( $ toInsert ) ) { $...
Apply token attributes .
8,849
private function grabAttribsBeforeMethodToken ( Tokens $ tokens , $ index ) { static $ tokenAttribsMap = [ T_PRIVATE => 'visibility' , T_PROTECTED => 'visibility' , T_PUBLIC => null , T_ABSTRACT => 'abstract' , T_FINAL => 'final' , T_STATIC => 'static' , ] ; return $ this -> grabAttribsBeforeToken ( $ tokens , $ index ...
Grab attributes before method token at given index .
8,850
private function grabAttribsBeforePropertyToken ( Tokens $ tokens , $ index ) { static $ tokenAttribsMap = [ T_VAR => null , T_PRIVATE => 'visibility' , T_PROTECTED => 'visibility' , T_PUBLIC => 'visibility' , T_STATIC => 'static' , ] ; $ result = $ this -> grabAttribsBeforeToken ( $ tokens , $ index , $ tokenAttribsMa...
Grab attributes before property token at given index .
8,851
private function grabAttribsBeforeToken ( Tokens $ tokens , $ index , array $ tokenAttribsMap , array $ attribs ) { while ( true ) { $ token = $ tokens [ -- $ index ] ; if ( ! $ token -> isArray ( ) ) { if ( $ token -> equalsAny ( [ '{' , '}' , '(' , ')' ] ) ) { break ; } continue ; } if ( array_key_exists ( $ token ->...
Grab attributes before token at given index .
8,852
public function confirmDelete ( Permission $ permission ) { $ this -> authorize ( 'delete' , Permission :: class ) ; return view ( 'laralum::pages.confirmation' , [ 'method' => 'DELETE' , 'action' => route ( 'laralum::permissions.destroy' , [ 'permission' => $ permission -> id ] ) , ] ) ; }
Displays a view to confirm delete .
8,853
protected function sendNotificationMail ( $ exception ) { $ message = array ( ) ; $ message [ ] = 'Title: ' . $ this -> getTitle ( $ exception ) ; $ message [ ] = 'Message: ' . PHP_EOL . $ this -> getMessage ( $ exception ) ; $ message [ ] = 'Server name: ' . filter_input ( INPUT_SERVER , 'SERVER_NAME' ) ; $ message [ ...
Sends an exception as notification e - mail
8,854
protected function isValid ( $ item ) { if ( ( ! $ item instanceof stdClass ) || ! isset ( $ item -> type ) || ! isset ( $ item -> modifiers ) ) { return false ; } if ( $ this -> doctypeValidationEnabled ) { if ( ! isset ( $ item -> content ) && ( ! $ this -> view -> plugin ( 'doctype' ) -> isHtml5 ( ) || ( ! $ this ->...
Determine if item is valid
8,855
public function describe ( $ table ) { $ schema = $ this -> db -> connection ( ) -> getDoctrineConnection ( ) -> getSchemaManager ( ) ; return $ this -> parseSchema ( $ schema -> listTableColumns ( $ table ) ) ; }
Describe all columns in a single table
8,856
protected function parseSchema ( array $ columns ) { $ schema = [ ] ; foreach ( $ columns as $ name => $ column ) { $ schema [ ] = [ 'name' => $ column -> getName ( ) , 'type' => $ column -> getType ( ) -> getName ( ) ] ; } return $ schema ; }
Convert the DBAL schema to an assoc array .
8,857
public static function flatten ( array $ value ) : array { $ result = [ ] ; array_walk_recursive ( $ value , function ( $ item ) use ( & $ result ) { $ result [ ] = $ item ; } ) ; return $ result ; }
Given a multi - dimensional array flatten the array to a single level .
8,858
public function requestAccessToken ( $ code , $ redirectUri , $ expiresIn = null , $ state = null ) { $ parameters = [ 'code' => $ code , 'grant_type' => 'authorization_code' , 'client_id' => $ this -> clientId , 'redirect_uri' => $ redirectUri , ] ; if ( $ expiresIn != null ) { $ parameters [ 'expires_in' ] = $ expire...
Request new Fitbit access token .
8,859
public function refreshAccessToken ( $ refreshToken , $ expiresIn = null ) { $ parameters = [ 'grant_type' => 'refresh_token' , 'refresh_token' => $ refreshToken , ] ; if ( $ expiresIn != null ) { $ parameters [ 'expires_in' ] = $ expiresIn ; } return $ this -> tokenRequest ( 'oauth2/token' , $ parameters ) ; }
Refresh Fitbit token .
8,860
private function tokenRequest ( $ namespace , $ parameters ) { $ client = new Client ( [ 'headers' => [ 'content-type' => 'application/x-www-form-urlencoded' , 'Authorization' => 'Basic ' . base64_encode ( $ this -> clientId . ':' . $ this -> secret ) , ] ] ) ; return $ client -> post ( self :: FITBIT_API_URL . $ names...
Request token action .
8,861
public function send ( $ url , $ method = 'GET' , $ data = [ ] ) { $ method = strtolower ( $ method ) ; $ settings = [ 'headers' => array_merge ( [ 'Authorization' => 'Bearer ' . $ this -> getToken ( ) , 'Content-Type' => 'application/x-www-form-urlencoded' , ] , $ this -> getHeaders ( ) ) , ] ; if ( $ method == 'post'...
Send authorized request to Fitbit API .
8,862
public function setExtension ( $ ext ) { $ this -> extension = $ ext ; if ( ! $ this -> extensionMap -> has ( $ ext ) ) { throw new Exceptions \ InvalidExtension ( $ ext ) ; } return $ this ; }
Sets the extension
8,863
public function process ( $ data = '' ) { $ this -> data = $ data ; $ ext = $ this -> extensionMap -> get ( $ this -> extension ) ; $ arr = $ ext -> load ( $ data ) -> toArray ( ) ; $ this -> paramBag = new ParamBag ( $ arr ) ; return true ; }
Loads an extension class to convert the data to an array and pass it back as a param bag
8,864
public function toNative ( ParamBag $ paramBag ) { $ ext = $ this -> extensionMap -> get ( $ this -> extension ) ; $ native = $ ext -> load ( $ paramBag -> all ( ) ) -> toNative ( ) ; return $ native ; }
Converts the parambag instance of the native extension format
8,865
public function transform ( $ lang ) { $ lang = $ this -> entityToArray ( Lang :: class , $ lang ) ; return [ 'code' => $ lang [ 'code' ] , 'i18n' => $ lang [ 'i18n' ] , 'isEnabled' => ( bool ) $ lang [ 'is_enabled' ] , 'isDefault' => ( bool ) $ lang [ 'is_default' ] , ] ; }
Transforms lang entity
8,866
public function decorate ( $ contents , array $ options = array ( ) ) { return $ this -> getTwigEnvironment ( ) -> render ( $ this -> getTemplateFilename ( ) , array_merge ( array ( 'contents' => $ contents ) , $ options ) ) ; }
Applies the relevant template upon the given content .
8,867
public function getAssets ( ) { $ finder = new Finder ( ) ; return iterator_to_array ( $ finder -> files ( ) -> in ( $ this -> path . DIRECTORY_SEPARATOR . $ this -> name ) -> depth ( '> 0' ) -> notName ( '*.twig' ) -> sortByName ( ) ) ; }
Returns a list of files that need to be copied to the destination location .
8,868
public function setBaseRequest ( ServerRequestInterface $ request ) { if ( $ request instanceof GlobalEnvironmentInterface && $ request -> isStale ( ) ) { throw new \ RuntimeException ( "Unable to set base request: ServerRequest is stale" ) ; } $ this -> baseRequest = $ request ; }
Set the base request
8,869
public function getBaseRequest ( ) { if ( ! isset ( $ this -> baseRequest ) ) { $ this -> baseRequest = new ServerRequest ( ) ; } $ request = $ this -> baseRequest ; if ( $ request instanceof GlobalEnvironmentInterface && $ request -> isStale ( ) === false ) { $ request = $ request -> withGlobalEnvironment ( true ) ; }...
Get the base request
8,870
public function setBaseResponse ( ResponseInterface $ response ) { if ( $ response instanceof GlobalEnvironmentInterface && $ response -> isStale ( ) ) { throw new \ RuntimeException ( "Unable to set base response: Response is stale" ) ; } $ this -> baseResponse = $ response ; }
Set the base response
8,871
public function getBaseResponse ( ) { if ( ! isset ( $ this -> baseResponse ) ) { $ this -> baseResponse = new Response ( ) ; } $ response = $ this -> baseResponse ; if ( $ response instanceof GlobalEnvironmentInterface && $ response -> isStale ( ) === false ) { $ response = $ response -> withGlobalEnvironment ( true )...
Get the base response
8,872
protected function resetOutput ( ) { if ( $ this -> baseResponse instanceof GlobalEnvironmentInterface ) { $ this -> baseResponse = $ this -> baseResponse -> revive ( ) ; } if ( isset ( $ this -> baseResponse ) && $ this -> baseResponse -> getBody ( ) instanceof OutputBufferStream ) { $ this -> baseResponse = $ this ->...
Reset the response
8,873
public function setHttpVersion ( $ version ) { $ pattern = '~^1\.[01]$~' ; if ( ! preg_match ( $ pattern , $ version ) ) return false ; $ this -> httpVersion = $ version ; return true ; }
Set the HTTP Protocol version of the Message
8,874
public function setRequestMethod ( $ method ) { if ( $ this -> getType ( ) !== self :: TYPE_REQUEST ) return false ; $ method = strtoupper ( $ method ) ; $ REQUEST_METHODS = array ( 'OPTIONS' , 'GET' , 'HEAD' , 'POST' , 'PUT' , 'DELETE' , 'TRACE' ) ; if ( ! in_array ( $ method , $ REQUEST_METHODS ) ) return false ; $ t...
Set the Request Method of the HTTP Message
8,875
public function transform ( $ option ) { $ options = $ this -> entityToArray ( OptionCategory :: class , $ option ) ; $ data = [ 'data' => [ ] ] ; foreach ( $ options as $ option ) { $ data [ 'data' ] [ ] = [ 'key' => $ option , ] ; } return $ data ; }
Transforms option category entity
8,876
public function query_vars ( array $ vars ) { if ( ! empty ( $ this -> query_var ) ) { foreach ( $ this -> query_var as $ var ) { if ( false === array_search ( $ var , $ vars ) ) { $ vars [ ] = $ var ; } } } return $ vars ; }
Add query var filter
8,877
public function rewrite_rules_array ( array $ rules ) { if ( ! empty ( $ this -> rewrites ) ) { $ rules = array_merge ( $ this -> rewrites , $ rules ) ; } return $ rules ; }
Register rewrite rules
8,878
final public function detect_title ( \ WP_Query & $ wp_query ) { if ( $ wp_query -> is_main_query ( ) && $ this -> is_valid_query ( $ wp_query ) ) { add_filter ( 'wp_title' , [ $ this , 'wp_title' ] , 10 , 3 ) ; } }
Add wp_title filter if required
8,879
protected function add_meta_query ( \ WP_Query & $ wp_query , array $ meta_query ) { $ old_query = ( array ) $ wp_query -> get ( 'meta_query' ) ; array_push ( $ old_query , $ meta_query ) ; $ wp_query -> set ( 'meta_query' , $ old_query ) ; }
Add meta query
8,880
public function clear ( $ name = null ) { if ( $ name === null ) { $ this -> data = array ( ) ; } elseif ( is_array ( $ name ) ) { foreach ( $ name as $ index ) unset ( $ this -> data [ $ index ] ) ; } else { unset ( $ this -> data [ $ name ] ) ; } }
clears a the entire data or only the given key
8,881
public function assign ( $ name , $ val = null ) { if ( is_array ( $ name ) ) { reset ( $ name ) ; while ( list ( $ k , $ v ) = each ( $ name ) ) $ this -> data [ $ k ] = $ v ; } else { $ this -> data [ $ name ] = $ val ; } }
assigns a value or an array of values to the data object
8,882
public function build ( $ action , array $ data , CliInput $ input , Mapping $ mapping ) { $ context = new ZMQContext ( ) ; $ socket = new ZMQSocket ( $ context , ZMQ :: SOCKET_REQ ) ; $ socket -> setSockOpt ( ZMQ :: SOCKOPT_LINGER , 0 ) ; if ( $ input -> getMapping ( ) === 'compact' ) { $ transportMapper = new Compact...
Build an Action Api class instance
8,883
public function getLastVersion ( $ post_id ) { $ qb = $ this -> createQueryBuilder ( 'p' ) ; $ qb -> where ( 'p.original=:post_id' ) -> orderBy ( 'p.createdAt' , 'DESC' ) -> setParameter ( ':post_id' , $ post_id ) ; $ result = $ qb -> getQuery ( ) -> setMaxResults ( 1 ) -> getResult ( Query :: HYDRATE_OBJECT ) ; if ( i...
Get last version for a post
8,884
public function getAllLastVersion ( ) { $ qb = $ this -> createQueryBuilder ( 'p' ) ; $ qb -> where ( 'p.original IS NULL AND p.state=:state' ) -> setParameter ( ':state' , DocumentModel :: STATE_PUBLISHED ) ; $ result = $ qb -> getQuery ( ) -> getResult ( ) ; $ return = array ( ) ; foreach ( $ result as $ original ) {...
Get all posts in their last version
8,885
private function attachFiles ( ) { if ( count ( $ this -> attachments ) === 0 ) { return ; } $ mimeMessage = $ this -> message -> getBody ( ) ; if ( is_string ( $ mimeMessage ) ) { $ originalBodyPart = new Mime \ Part ( $ mimeMessage ) ; $ originalBodyPart -> type = $ mimeMessage != strip_tags ( $ mimeMessage ) ? Mime ...
Attaches files to the message if any
8,886
public function post ( $ endpoint , array $ options = [ ] ) { $ jsonValues = [ ] ; if ( isset ( $ options [ 'json' ] ) ) { $ jsonValues = $ options [ 'json' ] ; } return $ this -> httpClient -> request ( 'POST' , 'https://api.craftcms.com/v1/' . $ endpoint , [ 'auth' => $ this -> setAuth ( ) , 'json' => $ jsonValues ] ...
Sends a POST request to the Craftnet API
8,887
public function load ( ) { if ( file_exists ( $ this -> filepath ) && ( $ contents = file_get_contents ( $ this -> filepath ) ) ) { $ yaml = new Parser ( ) ; $ config = $ yaml -> parse ( $ contents ) ; if ( null === $ config ) { $ config = array ( ) ; } $ processor = new Processor ( ) ; $ configDefinition = new ConfigD...
Process configuration and make sure the configuration format is as expected
8,888
public static function registerPlugin ( BlockView $ view , $ pluginName ) { $ optionsArray = $ view -> vars [ 'block_prefixes' ] ; array_splice ( $ optionsArray , - 1 , 1 , [ $ pluginName , end ( $ optionsArray ) ] ) ; $ view -> vars [ 'block_prefixes' ] = $ optionsArray ; }
Registers the plugin for the block type . You can use this method to add the additional block prefix that allow you to create an additional template for existing block type .
8,889
public static function normalizeTransValue ( $ text , $ parameters = null ) { if ( is_string ( $ text ) && ! empty ( $ text ) ) { $ text = [ 'label' => $ text ] ; } if ( ! empty ( $ parameters ) && is_array ( $ text ) && ! isset ( $ text [ 'parameters' ] ) ) { $ text [ 'parameters' ] = $ parameters ; } return $ text ; ...
Normalizes the given value to the format that can be translated by a renderer .
8,890
public static function processUrl ( BlockView $ view , Options $ options , $ required = false , $ prefix = null ) { $ pathName = null !== $ prefix ? $ prefix . '_path' : 'path' ; $ routeName = null !== $ prefix ? $ prefix . '_route_name' : 'route_name' ; if ( $ options -> isExistsAndNotEmpty ( $ pathName ) ) { $ view -...
Gets the url related options and pass them to the block view .
8,891
public function removePreProcessor ( $ callback ) { if ( ( $ index = array_search ( $ callback , $ this -> processors [ 'pre' ] , true ) ) !== false ) { unset ( $ this -> processors [ 'pre' ] [ $ index ] ) ; } elseif ( ( $ index = array_search ( 'Dwoo_Processor_' . str_replace ( 'Dwoo_Processor_' , '' , $ callback ) , ...
removes a preprocessor from the compiler
8,892
public function addPostProcessor ( $ callback , $ autoload = false ) { if ( $ autoload ) { $ name = str_replace ( 'Dwoo_Processor_' , '' , $ callback ) ; $ class = 'Dwoo_Processor_' . $ name ; if ( class_exists ( $ class , false ) ) { $ callback = array ( new $ class ( $ this ) , 'process' ) ; } elseif ( function_exist...
adds a postprocessor to the compiler it will be called before the template is compiled
8,893
protected function loadProcessor ( $ class , $ name ) { if ( ! class_exists ( $ class , false ) && ! function_exists ( $ class ) ) { try { $ this -> dwoo -> getLoader ( ) -> loadPlugin ( $ name ) ; } catch ( Dwoo_Exception $ e ) { throw new Dwoo_Exception ( 'Processor ' . $ name . ' could not be found in your plugin di...
internal function to autoload processors at runtime if required
8,894
protected function resolveSubTemplateDependencies ( $ function ) { $ body = $ this -> templatePlugins [ $ function ] [ 'body' ] ; foreach ( $ this -> templatePlugins as $ func => $ attr ) { if ( $ func !== $ function && ! isset ( $ attr [ 'called' ] ) && strpos ( $ body , 'Dwoo_Plugin_' . $ func ) !== false ) { $ this ...
checks what sub - templates are used in every sub - template so that we re sure they are all compiled
8,895
public function setScope ( $ scope , $ absolute = false ) { $ old = $ this -> scopeTree ; if ( $ scope === null ) { unset ( $ this -> scope ) ; $ this -> scope = null ; } if ( is_array ( $ scope ) === false ) { $ scope = explode ( '.' , $ scope ) ; } if ( $ absolute === true ) { $ this -> scope = & $ this -> data ; $ t...
sets the scope
8,896
public function addBlock ( $ type , array $ params , $ paramtype ) { $ class = 'Dwoo_Plugin_' . $ type ; if ( class_exists ( $ class , false ) === false ) { $ this -> dwoo -> getLoader ( ) -> loadPlugin ( $ type ) ; } $ params = $ this -> mapParams ( $ params , array ( $ class , 'init' ) , $ paramtype ) ; $ this -> sta...
adds a block to the top of the block stack
8,897
public function injectBlock ( $ type , array $ params ) { $ class = 'Dwoo_Plugin_' . $ type ; if ( class_exists ( $ class , false ) === false ) { $ this -> dwoo -> getLoader ( ) -> loadPlugin ( $ type ) ; } $ this -> stack [ ] = array ( 'type' => $ type , 'params' => $ params , 'custom' => false , 'class' => $ class , ...
injects a block at the top of the plugin stack without calling its preProcessing method
8,898
public function removeBlock ( $ type ) { $ output = '' ; $ pluginType = $ this -> getPluginType ( $ type ) ; if ( $ pluginType & Dwoo :: SMARTY_BLOCK ) { $ type = 'smartyinterface' ; } while ( true ) { while ( $ top = array_pop ( $ this -> stack ) ) { if ( $ top [ 'custom' ] ) { $ class = $ top [ 'class' ] ; } else { $...
removes the closest - to - top block of the given type and all other blocks encountered while going down the block stack
8,899
public function & findBlock ( $ type , $ closeAlong = false ) { if ( $ closeAlong === true ) { while ( $ b = end ( $ this -> stack ) ) { if ( $ b [ 'type' ] === $ type ) { return $ this -> stack [ key ( $ this -> stack ) ] ; } $ this -> push ( $ this -> removeTopBlock ( ) , 0 ) ; } } else { end ( $ this -> stack ) ; wh...
returns a reference to the first block of the given type encountered and optionally closes all blocks until it finds it