idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
9,400
public function onCaptured ( $ response ) { $ order = $ this -> owner -> Invoice ( ) ; if ( $ order -> exists ( ) ) { $ payment_amount = MathsHelper :: round ( $ this -> owner -> getAmount ( ) , 2 ) ; $ order_amount = MathsHelper :: round ( $ order -> Total , 2 ) ; if ( abs ( ( $ payment_amount - $ order_amount ) / $ o...
Process attached order when payment is taken
9,401
public function onRefunded ( $ response ) { $ order = $ this -> owner -> Invoice ( ) ; if ( $ order -> exists ( ) ) { $ order -> markRefunded ( ) ; $ order -> write ( ) ; } }
Process attached order when payment is refunded
9,402
public function addNamespace ( $ sNamespace , $ sDirectory , $ sExtension = '' ) { if ( ( $ sDirectory ) ) { jaxon ( ) -> addViewNamespace ( $ sNamespace , $ sDirectory , $ sExtension ) ; } }
Add a namespace to this view renderer
9,403
public function filter ( $ node ) { $ ret = array ( ) ; $ items = array ( $ node ) ; foreach ( $ this -> _factors as $ factor ) { $ ret = $ this -> _getNodesByFactor ( $ items , $ factor ) ; $ items = $ ret ; } return $ ret ; }
Gets all filtered subnodes of a given node .
9,404
private function _getNodesByFactor ( $ nodes , $ factor ) { $ ret = array ( ) ; foreach ( $ nodes as $ node ) { $ items = $ factor -> filter ( $ node ) ; $ ret = Dom :: mergeNodes ( $ ret , $ items ) ; } return $ ret ; }
Gets nodes from a list by a given factor .
9,405
public function mode ( $ mode = null ) { if ( $ mode !== null ) { $ this -> mode = ( string ) $ mode ; } return $ this -> mode ; }
Sets config mode
9,406
public function import ( array $ arr , $ prefix = null ) { $ imports = [ ] ; foreach ( $ arr as $ key => $ node ) { if ( strpos ( $ key , 'import' ) === 0 ) { $ mode = substr ( $ key , 7 ) ; if ( $ mode == '' || $ mode == $ this -> mode ) { $ imports = array_merge ( $ imports , $ node ) ; } continue ; } $ this -> stora...
Reads configuration properties from passed array
9,407
private function merge ( array $ merged , array $ array ) { foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) && isset ( $ merged [ $ key ] ) && is_array ( $ merged [ $ key ] ) ) { $ merged [ $ key ] = $ this -> merge ( $ merged [ $ key ] , $ value ) ; } else { $ merged [ $ key ] = $ value ; } } retur...
Merges arrays without changing duplicated keys into arrays
9,408
private function applyPrefix ( array $ array , $ prefix = null ) { if ( $ prefix === null ) { return $ array ; } $ result = [ ] ; foreach ( $ array as $ key => $ value ) { $ result [ $ prefix . self :: PREFIX_GLUE . $ key ] = $ value ; } return $ result ; }
Applies prefix to array keys
9,409
public function bindMany ( string $ class , array $ methods ) { array_map ( function ( $ closure ) use ( $ class ) { $ info = new ReflectionFunction ( $ closure ) ; $ doc = explode ( PHP_EOL , $ info -> getDocComment ( ) ) ; array_filter ( $ doc , function ( $ comment ) use ( $ class , $ closure ) { if ( str_contains (...
Bind multple methods at the same time
9,410
public function hasManyProps ( string $ class , array $ props ) { array_map ( function ( $ closure ) use ( $ class ) { $ info = new ReflectionFunction ( $ closure ) ; $ doc = explode ( PHP_EOL , $ info -> getDocComment ( ) ) ; array_filter ( $ doc , function ( $ comment ) use ( $ class , $ closure ) { if ( str_contains...
Add multiple props at the same time
9,411
protected function assertType ( string $ class , string $ param , ? \ ReflectionType $ reflType ) : void { if ( $ reflType === null || ! $ reflType instanceof \ ReflectionNamedType ) { throw new AutowireException ( "Unable to autowire {$class}: Unknown type for parameter '{$param}'." ) ; } if ( $ reflType -> isBuiltin ...
Assert that type can be used as container id .
9,412
protected function extractParamAnnotations ( string $ docComment ) : array { $ pattern = '/@param(?:\s+([^$"]\S+))?(?:\s+\$(\w+))?(?:\s+"([^"]++)")?/' ; if ( ! ( bool ) preg_match_all ( $ pattern , $ docComment , $ matches , PREG_SET_ORDER ) ) { return [ ] ; } $ annotations = [ ] ; foreach ( $ matches as $ index => $ m...
Get annotations for the constructor parameters . Annotated parameter types are not considered . Turning the class to a FQCN is more work than it s worth .
9,413
protected function getParamType ( \ ReflectionClass $ class , \ ReflectionParameter $ param ) : string { $ this -> assertType ( $ class -> getName ( ) , $ param -> getName ( ) , $ param -> getType ( ) ) ; return $ param -> getType ( ) -> getName ( ) ; }
Get the declared type of a parameter .
9,414
protected function determineDependencies ( \ ReflectionClass $ class , int $ skip ) : array { if ( ! $ class -> hasMethod ( '__construct' ) ) { return [ ] ; } $ constructor = $ class -> getMethod ( '__construct' ) ; $ docComment = $ constructor -> getDocComment ( ) ; $ annotations = is_string ( $ docComment ) ? $ this ...
Get all dependencies for a class constructor .
9,415
protected function getDependencies ( array $ identifiers ) : array { $ dependencies = [ ] ; foreach ( $ identifiers as $ index => $ identifier ) { $ dependencies [ $ index ] = ! $ identifier -> optional || $ this -> container -> has ( $ identifier -> key ) ? $ this -> container -> get ( $ identifier -> key ) : null ; }...
Get dependencies from the container
9,416
public function instantiate ( string $ class , ... $ args ) { $ refl = $ this -> reflection -> reflectClass ( $ class ) ; $ dependencyIds = $ this -> determineDependencies ( $ refl , count ( $ args ) ) ; $ dependencies = $ args + $ this -> getDependencies ( $ dependencyIds ) ; return $ refl -> newInstanceArgs ( $ depen...
Instantiate a new object automatically injecting dependencies
9,417
public function toArray ( ) { if ( \ is_array ( $ this -> data ) ) { return $ this -> data ; } if ( $ this -> data instanceof \ ArrayIterator ) { return iterator_to_array ( $ this -> data , false ) ; } if ( $ this -> data instanceof \ IteratorAggregate ) { return iterator_to_array ( $ this -> data -> getIterator ( ) , ...
Converts the Collection data to an array .
9,418
public static function newFromJSON ( $ data , $ token , $ url ) { $ object = new RemoteObject ( $ data [ 'name' ] ) ; $ object -> setContentType ( $ data [ 'content_type' ] ) ; $ object -> contentLength = ( int ) $ data [ 'bytes' ] ; $ object -> etag = ( string ) $ data [ 'hash' ] ; $ object -> lastModified = strtotime...
Create a new RemoteObject from JSON data .
9,419
public static function newFromHeaders ( $ name , $ headers , $ token , $ url , $ cdnUrl = NULL , $ cdnSslUrl = NULL ) { $ object = new RemoteObject ( $ name ) ; $ object -> setHeaders ( $ headers ) ; if ( isset ( $ headers [ 'ETag' ] ) ) { $ headers [ 'Etag' ] = $ headers [ 'ETag' ] ; } $ object -> setContentType ( $ h...
Create a new RemoteObject from HTTP headers .
9,420
public function useCDN ( $ url , $ sslUrl ) { $ this -> cdnUrl = $ url ; $ this -> cdnSslUrl = $ sslUrl ; return $ this ; }
Set the URL to this object in a CDN service .
9,421
public function url ( $ cached = FALSE , $ useSSL = TRUE ) { if ( $ cached && ! empty ( $ this -> cdnUrl ) ) { return $ useSSL ? $ this -> cdnSslUrl : $ this -> cdnUrl ; } return $ this -> url ; }
Get the URL to this object .
9,422
public function filterHeaders ( & $ headers ) { $ unset = array ( ) ; foreach ( $ headers as $ name => $ value ) { $ lower = strtolower ( $ name ) ; if ( isset ( $ this -> reservedHeaders [ $ lower ] ) ) { $ unset [ ] = $ name ; } } foreach ( $ unset as $ u ) { unset ( $ headers [ $ u ] ) ; } return $ this ; }
Filter the headers .
9,423
public function removeHeaders ( $ keys ) { foreach ( $ keys as $ key ) { unset ( $ this -> allHeaders [ $ key ] ) ; unset ( $ this -> additionalHeaders [ $ key ] ) ; } return $ this ; }
Given an array of header names .
9,424
public function content ( ) { if ( ! empty ( $ this -> content ) ) { return $ this -> content ; } $ response = $ this -> fetchObject ( TRUE ) ; $ content = $ response -> content ( ) ; $ check = md5 ( $ content ) ; if ( $ this -> isVerifyingContent ( ) && $ check != $ this -> etag ( ) ) { throw new ContentVerificationEx...
Get the content of this object .
9,425
public function stream ( $ refresh = FALSE ) { if ( ! $ refresh && isset ( $ this -> content ) ) { return $ this -> localFileStream ( ) ; } $ response = $ this -> fetchObject ( TRUE ) ; return $ response -> file ( ) ; }
Get the content of this object as a file stream .
9,426
protected function localFileStream ( ) { $ tmp = fopen ( 'php://temp' , 'rw' ) ; fwrite ( $ tmp , $ this -> content ( ) , $ this -> contentLength ( ) ) ; rewind ( $ tmp ) ; return $ tmp ; }
Transform a local copy of content into a file stream .
9,427
public function isDirty ( ) { if ( ! isset ( $ this -> content ) ) { return FALSE ; } if ( $ this -> etag != md5 ( $ this -> content ) ) { return TRUE ; } return FALSE ; }
Check whether there are unsaved changes .
9,428
public function refresh ( $ fetchContent = FALSE ) { unset ( $ this -> content ) ; $ response = $ this -> fetchObject ( $ fetchContent ) ; if ( $ fetchContent ) { $ this -> setContent ( $ response -> content ( ) ) ; } return $ this ; }
Rebuild the local object from the remote .
9,429
protected function fetchObject ( $ fetchContent = FALSE ) { $ method = $ fetchContent ? 'GET' : 'HEAD' ; $ client = \ HPCloud \ Transport :: instance ( ) ; $ headers = array ( 'X-Auth-Token' => $ this -> token , ) ; if ( empty ( $ this -> cdnUrl ) ) { $ response = $ client -> doRequest ( $ this -> url , $ method , $ he...
Helper function for fetching an object .
9,430
protected function extractFromHeaders ( $ response ) { $ this -> setContentType ( $ response -> header ( 'Content-Type' , $ this -> contentType ( ) ) ) ; $ this -> lastModified = strtotime ( $ response -> header ( 'Last-Modified' , 0 ) ) ; $ this -> etag = $ response -> header ( 'Etag' , $ this -> etag ) ; $ this -> co...
Extract information from HTTP headers .
9,431
private function routable ( ) : bool { $ routesFolder = config ( 'app.dir' ) . 'routes' . DIRECTORY_SEPARATOR ; if ( ! file_exists ( $ routesFolder . 'api.php' ) ) { $ this -> exception ( 'Could not find api routes.' ) ; return false ; } if ( ! file_exists ( $ routesFolder . 'web.php' ) ) { $ this -> exception ( 'Could...
Check if routes can be used
9,432
public static function cleanupRemovedItems ( ) { $ db = eZDB :: instance ( ) ; $ itemArray = array ( ) ; $ offset = 0 ; $ limit = 50 ; do { $ items = $ db -> arrayQuery ( 'SELECT node_id FROM ezm_pool' , array ( 'offset' => $ offset , 'limit' => $ limit ) ) ; if ( empty ( $ items ) ) break ; foreach ( $ items as $ item...
Clean up removed items from pool
9,433
protected function buildQuery ( $ params , $ separator = '&' , $ noQuotes = true , $ subList = false ) { if ( empty ( $ params ) ) { return '' ; } $ keys = $ this -> encode ( array_keys ( $ params ) ) ; $ values = $ this -> encode ( array_values ( $ params ) ) ; $ params = array_combine ( $ keys , $ values ) ; uksort (...
Generates an oauth standard query
9,434
protected function encode ( $ string ) { if ( is_array ( $ string ) ) { foreach ( $ string as $ i => $ value ) { $ string [ $ i ] = $ this -> encode ( $ value ) ; } return $ string ; } if ( is_scalar ( $ string ) ) { return str_replace ( '%7E' , '~' , rawurlencode ( $ string ) ) ; } return null ; }
Generates an oauth standard encoding
9,435
protected function parseString ( $ string ) { $ array = array ( ) ; if ( strlen ( $ string ) < 1 ) { return $ array ; } $ keyvalue = explode ( '&' , $ query_string ) ; foreach ( $ keyvalue as $ pair ) { list ( $ k , $ v ) = explode ( '=' , $ pair , 2 ) ; if ( isset ( $ query_array [ $ k ] ) ) { if ( is_scalar ( $ query...
Oauth standard parseString
9,436
public static function cardNumber ( Validator $ validator , $ data , $ pattern , $ rule ) { foreach ( Validator :: getValues ( $ data , $ pattern ) as $ attribute => $ value ) { if ( null === $ value || empty ( $ value ) ) { continue ; } $ number = preg_replace ( '/\D/' , '' , $ value ) ; $ numberLength = strlen ( $ nu...
card - number
9,437
public static function getConfig ( array $ appConfig = [ ] ) : array { $ configs = DEPConfig :: $ appdir . 'config' . DIRECTORY_SEPARATOR . '*.php' ; foreach ( \ glob ( $ configs ) as $ config ) { $ service = require $ config ; if ( is_array ( $ service ) ) { $ path = basename ( $ config ) ; $ name = \ substr ( $ path ...
Get config files
9,438
final public function getHtml ( ) { $ result = $ this -> renderHtml ( ) ; if ( is_array ( $ result ) && array_key_exists ( 'RenderView' , $ result ) ) { $ result [ 'RenderView' ] [ 'options' ] [ 'block_manager' ] = $ this ; } return $ result ; }
Returns the block s html content or an array which contains the view to be rendered with its options
9,439
public function toArray ( ) { if ( null === $ this -> alBlock ) { return array ( ) ; } $ content = $ this -> replaceHtmlCmsActive ( ) ; if ( null === $ content ) { $ content = $ this -> getHtml ( ) ; } $ blockManager = array ( ) ; $ blockManager [ "HideInEditMode" ] = $ this -> getHideInEditMode ( ) ; $ blockManager [ ...
Converts the BlockManager object into an array
9,440
protected function add ( array $ values ) { $ values = $ this -> dispatchBeforeOperationEvent ( '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Block\BeforeBlockAddingEvent' , BlockEvents :: BEFORE_ADD_BLOCK , $ values , 'exception_block_adding_aborted' ) ; $ this -> validator -> checkEmptyParams ( $ value...
Adds a new block to the Block table
9,441
protected function edit ( array $ values ) { $ values = $ this -> dispatchBeforeOperationEvent ( '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Block\BeforeBlockEditingEvent' , BlockEvents :: BEFORE_EDIT_BLOCK , $ values , 'exception_block_editing_aborted' ) ; try { $ this -> validator -> checkEmptyParams...
Edits the current block object
9,442
public function all ( ) { $ query = new \ Peyote \ Select ( $ this -> db_table ( ) ) ; $ query -> columns ( 'name' ) ; $ result = $ this -> db -> fetch ( $ query ) ; foreach ( $ result as $ r ) { $ list [ ] = $ r [ 'name' ] ; } return $ list ; }
Display all settings
9,443
public function check ( $ userAgent = null ) { if ( empty ( $ userAgent ) ) { $ userAgent = $ this -> server [ 'http_user_agent' ] ; } $ this -> userAgent = $ userAgent ; switch ( $ this -> method ) { case "browscap" : if ( ! $ this -> browscap ) { if ( $ this -> browscap = new Browscap ( $ this -> config [ 'cache_dir'...
Accept a user agent to check and try to find a match
9,444
public function doesAcceptLanguage ( $ language = 'en' ) { return ( in_array ( strtolower ( $ language ) , $ this -> getAcceptLanguages ( ) , true ) ) ? true : false ; }
Check if the current browser accepts a specific language
9,445
public function doesAcceptCharset ( $ charset = 'utf-8' ) { return ( in_array ( strtolower ( $ charset ) , $ this -> getAcceptCharsets ( ) , true ) ) ? true : false ; }
Check if the current browser accepts a specific character set
9,446
public function registerTaxonomy ( ) { $ namePlural = __ ( 'Topics' , 'customer-feedback' ) ; $ nameSingular = __ ( 'Topic' , 'customer-feedback' ) ; $ labels = array ( 'name' => $ namePlural , 'singular_name' => $ nameSingular , 'search_items' => sprintf ( __ ( 'Search %s' , 'customer-feedback' ) , $ namePlural ) , 'a...
Register a topic taxonomy for post type customer - feedback .
9,447
public function pageMetaBoxContent ( ) { global $ post ; $ parent = get_post_meta ( $ post -> ID , 'customer_feedback_page_reference' , true ) ; $ parent = get_post ( $ parent ) ; echo '<p><a href="' . get_permalink ( $ parent ) . '">' . $ parent -> post_title . '</a> (' . get_permalink ( $ parent ) . ')</p>' ; }
Answer page parent metabox
9,448
public function addPageSummaryMetaBox ( $ postType , $ post ) { $ allowedPostTypes = get_field ( 'customer_feedback_posttypes' , 'option' ) ; if ( ! isset ( $ post -> ID ) || ( is_array ( $ allowedPostTypes ) && ! in_array ( $ postType , $ allowedPostTypes ) ) ) { return ; } $ answers = Responses :: getResponses ( $ po...
Display summary metabox
9,449
public function renderSummary ( $ postId , $ data ) { $ totalCount = 0 ; echo '<table id="customer-feedback-summary" cellspacing="0" cellpadding="0"><tbody>' ; foreach ( $ data [ 'args' ] [ 'results' ] as $ count ) { $ totalCount += $ count ; } foreach ( $ data [ 'args' ] [ 'results' ] as $ answer => $ count ) { $ answ...
Content of summary metabox
9,450
public function listColumns ( $ columns ) { $ columns = array ( 'cb' => '<input type="checkbox">' , 'title' => __ ( 'Page' , 'customer-feedback' ) , 'id' => __ ( 'ID' , 'customer-feedback' ) , 'answer' => __ ( 'Answer' , 'customer-feedback' ) , 'hasComment' => __ ( 'Has comment' , 'customer-feedback' ) , 'topic' => __ ...
Setup list table columns
9,451
public function listColumnsContent ( $ column , $ postId ) { switch ( $ column ) { case 'id' : echo $ postId ; break ; case 'answer' : if ( get_post_meta ( $ postId , 'customer_feedback_answer' , true ) == 'no' ) { echo '<span style="color:#BA3030;">' . __ ( 'No' ) . '</span>' ; } elseif ( get_post_meta ( $ postId , 'c...
Add content to list table columns
9,452
public function listColumnsSortingQuery ( $ query ) { if ( ! is_admin ( ) || ! $ query -> is_main_query ( ) || $ query -> get ( 'post_type' ) != $ this -> postTypeSlug ) { return ; } if ( ! empty ( $ _GET [ 'feedback_topic' ] ) ) { $ query -> set ( 'tax_query' , array ( 'relation' => 'AND' , array ( 'taxonomy' => 'feed...
Handles the sorting of the table columns
9,453
public function submitResponse ( ) { $ insertedId = 'false' ; $ postId = ( isset ( $ _POST [ 'postid' ] ) && is_numeric ( $ _POST [ 'postid' ] ) ) ? $ _POST [ 'postid' ] : null ; $ answer = ( isset ( $ _POST [ 'answer' ] ) && strlen ( $ _POST [ 'answer' ] ) > 0 ) ? $ _POST [ 'answer' ] : null ; $ cookieExpireDays = 5 ;...
Saves the Yes or No response as counters in metadata
9,454
public function submitComment ( ) { $ answerId = ( isset ( $ _POST [ 'answerid' ] ) && is_numeric ( $ _POST [ 'answerid' ] ) ) ? $ _POST [ 'answerid' ] : null ; $ postId = ( isset ( $ _POST [ 'postid' ] ) && is_numeric ( $ _POST [ 'postid' ] ) ) ? $ _POST [ 'postid' ] : null ; $ comment = ( isset ( $ _POST [ 'comment' ...
Save a comment response as metadata for the page commented on
9,455
public function setCurrentNamespace ( $ sNamespace ) { $ this -> sDirectory = '' ; $ this -> sExtension = '' ; if ( key_exists ( $ sNamespace , $ this -> aDirectories ) ) { $ this -> sDirectory = rtrim ( $ this -> aDirectories [ $ sNamespace ] [ 'path' ] , '/' ) . '/' ; $ this -> sExtension = '.' . ltrim ( $ this -> aD...
Find the namespace of the template being rendered
9,456
public function errors ( $ errors ) { $ this -> success = false ; $ this -> data [ 'errors' ] = $ errors instanceof MessageBag ? $ errors -> toArray ( ) : $ errors ; return $ this ; }
Set response errors
9,457
public function findAllByEntityId ( $ entityId ) { $ params = array ( ParamNames :: ENTITY_ID => $ entityId ) ; $ this -> customerVarcharsStmt -> execute ( $ params ) ; return $ this -> customerVarcharsStmt -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; }
Load s and return s the varchar attributes for the passed entity ID .
9,458
public function addResources ( $ dirs ) { $ finder = Finder :: create ( ) -> files ( ) -> filter ( function ( \ SplFileInfo $ file ) { return 2 === substr_count ( $ file -> getBasename ( ) , '.' ) && preg_match ( '/\.\w+$/' , $ file -> getBasename ( ) ) ; } ) -> in ( $ dirs ) ; foreach ( $ finder as $ file ) { list ( $...
add translation resources
9,459
public function getViaIds ( $ select = null ) { return ( new Query ( ) ) -> from ( $ this -> viaTable ) -> select ( ( $ select ? : array_values ( $ this -> relationAttribute ) ) ) -> where ( $ this -> condition ) ; }
Gets relation table via unique data
9,460
public function deleteViaIds ( $ ids ) { return ! $ ids || \ Yii :: $ app -> db -> createCommand ( ) -> delete ( $ this -> viaTable , array_merge ( $ this -> condition , [ reset ( $ this -> relationAttribute ) => $ ids ] ) ) -> execute ( ) ; }
Deletes relation data
9,461
public function addViaIds ( $ ids , $ defaultData = [ ] ) { if ( ! $ ids ) { return true ; } foreach ( $ ids as $ key => $ id ) { $ id = is_array ( $ id ) ? $ id : [ reset ( $ this -> relationAttribute ) => $ id ] ; $ ids [ $ key ] = array_merge ( $ id , $ this -> condition , $ defaultData ) ; } MigrationHelper :: inse...
Adds relation data
9,462
public function cloneRelation ( ActiveRecord $ target , $ except = [ 'id' ] ) { $ ids = $ this -> getViaIds ( [ '*' ] ) -> all ( ) ; array_walk ( $ ids , function ( & $ v ) use ( $ except ) { $ v = array_diff_key ( $ v , array_flip ( $ except ) ) ; } ) ; return ( new static ( $ target , $ this -> relationName ) ) -> ad...
Clones original model relations to target model
9,463
public static function cloneRelations ( $ sources , $ clones , $ relations = [ ] ) { if ( ! is_array ( $ sources ) ) { $ sources = [ $ sources ] ; $ clones = [ $ clones ] ; } foreach ( $ sources as $ k => $ source ) { foreach ( $ relations as $ j => $ name ) { list ( $ name , $ except ) = is_array ( $ name ) ? [ $ j , ...
Clones relations from one models array to another
9,464
public function add_template_directory ( $ directory , $ namespace = null ) { if ( $ this -> filesystem_loader === null ) { $ this -> filesystem_loader = new \ Twig_Loader_Filesystem ( $ directory ) ; } if ( $ namespace === null ) { $ this -> filesystem_loader -> addPath ( $ directory ) ; } else { $ this -> filesystem_...
Set Template dir
9,465
public function getType ( $ classIdentifier ) { if ( array_key_exists ( $ classIdentifier , $ this -> classIdentifierToTypeNameMap ) ) { return $ this -> classIdentifierToTypeNameMap [ $ classIdentifier ] ; } else { throw new FormatNotSupportedException ( 'There is no target type for class name "' . $ classIdentifier ....
Returns the public type string for a given class name .
9,466
public function onKernelRequest ( GetResponseEvent $ event ) { $ token = $ this -> securityContext -> getToken ( ) ; if ( null !== $ token ) { $ user = $ token -> getUser ( ) ; if ( null !== $ user ) { $ errorMessage = '' ; $ userId = $ user -> getId ( ) ; try { $ this -> resourcesLocker -> unlockExpiredResources ( ) ;...
Listen to onKernelRequest event to lock a resource
9,467
protected function loadMessages ( $ category , $ language ) { $ messageFile = $ this -> getMessageFilePath ( $ category , $ language ) ; $ messages = $ this -> loadMessagesFromFile ( $ messageFile ) ; $ fallbackLanguage = substr ( $ language , 0 , 2 ) ; if ( $ fallbackLanguage != $ language ) { $ fallbackMessageFile = ...
Loads the message translation for the specified language and category . If translation for specific locale code such as en - US isn t found it tries more generic en .
9,468
public function getOne ( $ field = null ) { $ row = $ this -> statement -> fetch ( PDO :: FETCH_ASSOC ) ; return null === $ field ? $ row : $ row [ $ field ] ; }
Get one row to PDOStatement .
9,469
public function getModel ( $ model ) { $ model = str_replace ( ':' , '\\' , $ model ) ; if ( ! class_exists ( $ model ) ) { throw new ModelNotFoundException ( $ model ) ; } return new $ model ( $ this ) ; }
Get table repository object .
9,470
public static function storeCustomFieldResults ( $ request , $ customFieldGroup , $ resource , $ objectId , $ lang ) { $ customFieldGroup = CustomFieldGroup :: find ( $ customFieldGroup ) ; $ customFields = CustomField :: getRecords ( [ 'lang_026' => $ lang , 'group_id_026' => $ customFieldGroup -> id_025 ] ) ; $ dataT...
Function to store custom field
9,471
public function getDataCellValue ( $ model , $ key , $ index ) { if ( $ this -> value !== null ) { if ( is_string ( $ this -> value ) ) { return ArrayHelper :: getValue ( $ model , $ this -> value ) ; } else { return call_user_func ( $ this -> value , $ model , $ key , $ index , $ this ) ; } } elseif ( $ this -> attrib...
Returns the data cell value .
9,472
public function generateExtension ( $ namespace , $ dir , $ themeName , array $ templates ) { $ themeBasename = str_replace ( 'Bundle' , '' , $ themeName ) ; $ extensionAlias = Container :: underscore ( $ themeBasename ) ; $ templateFiles = array_map ( function ( $ template ) { return basename ( $ template [ "name" ] ,...
Generates the extension file
9,473
public function filter ( $ node ) { $ ret = array ( ) ; $ items = $ this -> _combinator -> filter ( $ node , $ this -> _element -> getTagName ( ) ) ; foreach ( $ items as $ item ) { if ( $ this -> _element -> match ( $ item ) ) { array_push ( $ ret , $ item ) ; } } $ filters = $ this -> _element -> getFilters ( ) ; for...
Gets the elements that matches the factor .
9,474
public static function byName ( Client $ client , string $ name ) : self { $ tags = self :: byNames ( $ client , [ $ name ] , self :: ORDER_NAME , false ) ; if ( count ( $ tags ) === 0 ) { throw new TagNotFoundException ( sprintf ( 'Tag with name %s not found' , $ name ) ) ; } return $ tags [ 0 ] ; }
Search tag by name or throw exception if nothing found .
9,475
public static function byNames ( Client $ client , array $ names , string $ orderBy = self :: ORDER_NAME , bool $ hideEmpty = true ) : array { if ( ! self :: isValidOrderingMethod ( $ orderBy ) ) { throw new InvalidArgumentException ( 'Invalid order method' ) ; } $ query = [ 'search' => [ 'order' => $ orderBy , 'hide_e...
Search tags by names .
9,476
function setResolverOptions ( $ options ) { if ( method_exists ( $ this -> _resolver ( ) , 'with' ) ) $ this -> _resolver ( ) -> with ( $ options ) ; return $ this ; }
Proxy to Resolver Options
9,477
static function Loader ( ) { if ( ! self :: $ default_resolver ) { $ resolver = new LoaderAggregate ; $ resolver -> attach ( new LoaderMapResource , 100 ) ; self :: $ default_resolver = $ resolver ; } return self :: $ default_resolver ; }
Default Loader Resolver
9,478
public function setTransformer ( $ transformer ) { if ( $ transformer !== null ) { if ( ! $ this -> isValidTransformer ( $ transformer ) ) { throw new InvalidTransformerException ( 'Transformer must be a callable or implement TransformerInterface' ) ; } } $ this -> transformer = $ transformer ; return $ this ; }
Set the transformer .
9,479
public function isValidTransformer ( $ transformer ) : bool { if ( $ transformer instanceof TransformerInterface ) { return true ; } if ( \ is_callable ( $ transformer ) ) { return true ; } return false ; }
Determines if the given argument is a valid transformer .
9,480
public function paginate ( $ perPage , $ page = null ) { if ( empty ( $ page ) ) { $ page = request ( 'page' , 1 ) ; } $ offset = ( $ page * $ perPage ) - $ perPage ; $ collection = $ this -> all ( ) ; $ newItems = array_slice ( $ collection , $ offset , $ perPage , true ) ; return $ this -> createChildCollection ( $ n...
Paginate collection items
9,481
public function decrypt ( $ y ) { $ t = "" ; $ x = "" ; $ ysize = strlen ( $ y ) ; for ( $ i = 0 ; $ i < $ ysize ; $ i += 16 ) { for ( $ j = 0 ; $ j < 16 ; $ j ++ ) { if ( ( $ i + $ j ) < $ ysize ) $ t [ $ j ] = $ y [ $ i + $ j ] ; else $ t [ $ j ] = chr ( 0 ) ; } $ x .= $ this -> decryptBlock ( $ t ) ; } return $ x ; ...
Decrypts an aribtrary length String .
9,482
private function addSelect2 ( ArrayNodeDefinition $ rootNode ) { $ rootNode -> children ( ) -> arrayNode ( 'select2' ) -> canBeUnset ( ) -> treatNullLike ( [ 'enabled' => true ] ) -> treatTrueLike ( [ 'enabled' => true ] ) -> addDefaultsIfNotSet ( ) -> children ( ) -> booleanNode ( 'enabled' ) -> defaultTrue ( ) -> end...
Add configuration Select2 .
9,483
public function getModel ( $ table , $ name , $ value ) { $ result = $ this -> getRow ( $ table , $ name , $ value ) ; if ( is_null ( $ result ) ) { return null ; } return $ this -> model ( ) -> setTable ( $ table ) -> set ( $ result ) ; }
Returns a model given the column name and the value
9,484
public static function loadPDO ( PDO $ connection ) { $ reflection = new ReflectionClass ( static :: class ) ; $ instance = $ reflection -> newInstanceWithoutConstructor ( ) ; return $ instance -> connect ( $ connection ) ; }
Adaptor used to force a connection to the handler
9,485
public function transaction ( $ callback ) { $ connection = $ this -> getConnection ( ) ; $ connection -> beginTransaction ( ) ; if ( $ callback instanceof Closure ) { $ callback = $ callback -> bindTo ( $ this , get_class ( $ this ) ) ; } if ( call_user_func ( $ callback , $ this ) === false ) { $ connection -> rollBa...
Sets up a transaction call
9,486
public function updateRows ( $ table , array $ settings , $ filters = null , $ bind = true ) { $ query = $ this -> getUpdateQuery ( $ table ) ; foreach ( $ settings as $ key => $ value ) { if ( is_null ( $ value ) || is_bool ( $ value ) ) { $ query -> set ( $ key , $ value ) ; continue ; } if ( $ bind === true || ( is_...
Updates rows that match a filter given the update settings
9,487
public function execute ( Arguments $ args , ConsoleIo $ io ) { $ questions = $ args -> getOption ( 'force' ) ? Hash :: extract ( $ this -> questions , '{n}[default=Y]' ) : $ this -> questions ; foreach ( $ questions as $ question ) { is_true_or_fail ( [ 'question' , 'default' , 'command' ] === array_keys ( $ question ...
Executes all available commands
9,488
public function getTarget ( Args $ args ) { if ( ! is_object ( $ this -> target ) && $ this -> getClass ( ) ) { $ class = $ this -> getClass ( ) ; $ targetObject = new $ class ( $ args ) ; if ( ! $ targetObject instanceof Command ) { $ command = $ this -> getCommand ( ) ; throw new Exception ( "$command: $class is not ...
Get command object if initialized
9,489
protected function add ( array $ values ) { $ values = $ this -> dispatchBeforeOperationEvent ( '\RedKiteLabs\RedKiteCms\RedKiteCmsBundle\Core\Event\Content\Page\BeforePageAddingEvent' , PageEvents :: BEFORE_ADD_PAGE , $ values , array ( 'message' => 'exception_page_adding_aborted' , 'domain' => 'exceptions' , ) ) ; tr...
Adds a new Page object from the given params
9,490
protected function resetHome ( ) { try { $ page = $ this -> pageRepository -> homePage ( ) ; if ( null !== $ page ) { return $ this -> pageRepository -> setRepositoryObject ( $ page ) -> save ( array ( 'IsHome' => 0 ) ) ; } return true ; } catch ( \ Exception $ e ) { throw $ e ; } }
Degrades the home page to normal page
9,491
public function authenticate ( array $ ops ) { $ url = $ this -> url ( ) . '/tokens' ; $ envelope = array ( 'auth' => $ ops , ) ; $ body = json_encode ( $ envelope ) ; $ headers = array ( 'Content-Type' => 'application/json' , 'Accept' => self :: ACCEPT_TYPE , 'Content-Length' => strlen ( $ body ) , ) ; $ client = \ HP...
Send an authentication request .
9,492
public function authenticateAsUser ( $ username , $ password , $ tenantId = NULL , $ tenantName = NULL ) { $ ops = array ( 'passwordCredentials' => array ( 'username' => $ username , 'password' => $ password , ) , ) ; if ( ! empty ( $ tenantId ) ) { $ ops [ 'tenantId' ] = $ tenantId ; } elseif ( ! empty ( $ tenantName ...
Authenticate to Identity Services with username password and either tenant ID or tenant Name .
9,493
public function authenticateAsAccount ( $ account , $ key , $ tenantId = NULL , $ tenantName = NULL ) { $ ops = array ( 'apiAccessKeyCredentials' => array ( 'accessKey' => $ account , 'secretKey' => $ key , ) , ) ; if ( ! empty ( $ tenantId ) ) { $ ops [ 'tenantId' ] = $ tenantId ; } elseif ( ! empty ( $ tenantName ) )...
Authenticate to HP Helion Public Cloud using your account ID and access key .
9,494
public function isExpired ( ) { $ details = $ this -> tokenDetails ( ) ; if ( empty ( $ details [ 'expires' ] ) ) { return TRUE ; } $ currentDateTime = new \ DateTime ( 'now' ) ; $ expireDateTime = new \ DateTime ( $ details [ 'expires' ] ) ; return $ currentDateTime > $ expireDateTime ; }
Check whether the current identity has an expired token .
9,495
public function serviceCatalog ( $ type = NULL ) { if ( empty ( $ type ) ) { return $ this -> serviceCatalog ; } $ list = array ( ) ; foreach ( $ this -> serviceCatalog as $ entry ) { if ( $ entry [ 'type' ] == $ type ) { $ list [ ] = $ entry ; } } return $ list ; }
Get the service catalog optionaly filtering by type .
9,496
public function tenants ( $ token = NULL ) { $ url = $ this -> url ( ) . '/tenants' ; if ( empty ( $ token ) ) { $ token = $ this -> token ( ) ; } $ headers = array ( 'X-Auth-Token' => $ token , 'Accept' => 'application/json' , ) ; $ client = \ HPCloud \ Transport :: instance ( ) ; $ response = $ client -> doRequest ( ...
Get a list of all tenants associated with this account .
9,497
public function rescopeUsingTenantId ( $ tenantId ) { $ url = $ this -> url ( ) . '/tokens' ; $ token = $ this -> token ( ) ; $ data = array ( 'auth' => array ( 'tenantId' => $ tenantId , 'token' => array ( 'id' => $ token , ) , ) , ) ; $ body = json_encode ( $ data ) ; $ headers = array ( 'Accept' => self :: ACCEPT_TY...
Rescope the authentication token to a different tenant .
9,498
protected function handleResponse ( $ response ) { $ json = json_decode ( $ response -> content ( ) , TRUE ) ; $ this -> tokenDetails = $ json [ 'access' ] [ 'token' ] ; $ this -> userDetails = $ json [ 'access' ] [ 'user' ] ; $ this -> serviceCatalog = $ json [ 'access' ] [ 'serviceCatalog' ] ; return $ this ; }
Given a response object populate this object .
9,499
public static function Start ( ) { global $ _SERVER ; if ( ! phoxy_conf ( ) [ "is_ajax_request" ] && phoxy_conf ( ) [ "api_csrf_prevent" ] ) die ( "Request aborted due API direct CSRF warning" ) ; if ( phoxy_conf ( ) [ "buffered_output" ] ) ob_start ( ) ; global $ _GET ; $ get_param = phoxy :: Config ( ) [ "get_api_par...
Begin default phoxy behaviour