idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
56,500
|
protected function setFileFileManager ( ) { $ initial_path = $ this -> scanner -> getInitialPath ( ) ; $ initial_absolute_path = $ this -> scanner -> getInitialPath ( true ) ; $ this -> data_path = $ this -> getQuery ( 'path' , $ initial_path ) ; if ( empty ( $ this -> data_path ) ) { $ this -> data_path = $ initial_path ; } $ this -> data_absolute_path = gplcart_file_absolute ( $ this -> data_path ) ; if ( gplcart_path_starts ( $ this -> data_absolute_path , $ initial_absolute_path ) && file_exists ( $ this -> data_absolute_path ) ) { $ this -> data_access = true ; $ this -> data_file = new SplFileInfo ( $ this -> data_absolute_path ) ; } else { $ this -> data_access = false ; } $ this -> setSelectedFileManager ( ) ; }
|
Sets the current working file path
|
56,501
|
protected function setSelectedFileManager ( ) { foreach ( $ this -> session -> get ( 'file_manager_selected' , array ( ) ) as $ path ) { $ file = new SplFileInfo ( gplcart_file_absolute ( $ path ) ) ; if ( is_object ( $ file ) ) { $ this -> data_selected [ $ path ] = $ file ; } } }
|
Prepare and set selected files
|
56,502
|
public function viewFileManager ( ) { $ this -> setFileFileManager ( ) ; $ this -> setAccessFileManager ( ) ; $ this -> setDataMessagesFileManager ( ) ; $ this -> setData ( 'access' , $ this -> data_access ) ; $ this -> setData ( 'command' , $ this -> data_command ) ; $ this -> setData ( 'selected' , $ this -> data_selected ) ; $ this -> setData ( 'tabs' , $ this -> getTabsFileManager ( ) ) ; $ this -> setData ( 'actions' , $ this -> getActionsFileManager ( ) ) ; $ this -> setData ( 'process_selected' , $ this -> isQuery ( 'selected' ) ) ; $ this -> submitFileManager ( ) ; $ this -> setDataContendFileManager ( ) ; $ rendered = $ this -> render ( 'file_manager|filemanager' , $ this -> data ) ; if ( $ this -> isQuery ( 'output' ) ) { $ this -> response -> outputHtml ( $ rendered ) ; } $ this -> setJsFileManager ( ) ; $ this -> setCssFileManager ( ) ; $ this -> setTitleFileManager ( ) ; $ this -> setBreadcrumbFileManager ( ) ; $ this -> setData ( 'rendered_filemanager' , $ rendered ) ; $ this -> outputViewFileManager ( ) ; }
|
Displays the file manager page
|
56,503
|
protected function setDataContendFileManager ( ) { if ( $ this -> data_access ) { $ data = $ this -> command -> getView ( $ this -> data_command , array ( $ this -> data_file , $ this ) ) ; if ( is_string ( $ data ) ) { $ this -> setMessageFileManager ( $ data , 'warning' ) ; } else { settype ( $ data , 'array' ) ; $ template_data = reset ( $ data ) ; $ template = key ( $ data ) ; $ template_data [ 'file' ] = $ this -> data_file ; $ template_data [ 'breadcrumbs' ] = $ this -> getPathBreadcrumbsFileManager ( ) ; $ rendered = $ this -> render ( $ template , array_merge ( $ template_data , $ this -> data ) ) ; $ this -> setData ( 'content' , $ rendered ) ; } } }
|
Sets rendered HTML for the current command
|
56,504
|
protected function setAccessFileManager ( ) { $ path_from_query = $ this -> getQuery ( 'cmd' , 'list' ) ; $ this -> data_command = $ this -> command -> get ( $ path_from_query ) ; if ( empty ( $ this -> data_command [ 'command_id' ] ) ) { return $ this -> data_access = false ; } if ( ! $ this -> access ( "module_file_manager_{$this->data_command['command_id']}" ) ) { return $ this -> data_access = false ; } if ( ! empty ( $ this -> data_selected ) && $ this -> isQuery ( 'selected' ) ) { return $ this -> data_access = true ; } if ( ! $ this -> command -> isAllowed ( $ this -> data_command , $ this -> data_file ) ) { return $ this -> data_access = false ; } if ( $ this -> accessPathAccessFileManager ( $ this -> data_path ) ) { return $ this -> data_access = true ; } return $ this -> data_access = $ this -> access ( 'module_file_manager' ) ; }
|
Sets access to the current path
|
56,505
|
protected function accessPathAccessFileManager ( $ path ) { $ role_id = $ this -> getUser ( 'role_id' ) ; $ settings = $ this -> module -> getSettings ( 'file_manager' ) ; if ( empty ( $ settings [ 'access' ] [ $ role_id ] ) ) { return true ; } foreach ( $ settings [ 'access' ] [ $ role_id ] as $ pattern ) { if ( gplcart_path_match ( $ path , $ pattern ) ) { return true ; } } return false ; }
|
Whether the current user has access to the file
|
56,506
|
protected function getPathBreadcrumbsFileManager ( ) { $ initial_path = $ this -> scanner -> getInitialPath ( ) ; $ breadcrumbs = array ( array ( 'text' => $ this -> text ( 'Home' ) , 'path' => $ initial_path ) ) ; $ path = '' ; foreach ( explode ( '/' , $ this -> data_path ) as $ folder ) { $ path .= "$folder/" ; $ trimmed_path = trim ( $ path , '/' ) ; if ( $ trimmed_path !== $ initial_path && $ this -> accessPathAccessFileManager ( $ trimmed_path ) ) { $ breadcrumbs [ ] = array ( 'text' => $ folder , 'path' => $ trimmed_path ) ; } } $ breadcrumbs [ count ( $ breadcrumbs ) - 1 ] [ 'path' ] = null ; return $ breadcrumbs ; }
|
Returns an array of path breadcrumbs
|
56,507
|
protected function setMessageFileManager ( $ message , $ severity , $ once = false ) { if ( $ once ) { $ this -> session -> setMessage ( $ message , $ severity , 'file_manager_messages' ) ; } else { $ messages = $ this -> getData ( "messages.$severity" , array ( ) ) ; $ messages [ ] = $ message ; $ this -> setData ( "messages.$severity" , $ messages ) ; } }
|
Sets file manager messages
|
56,508
|
protected function submitSelectedFileManager ( ) { $ command_id = $ this -> getPosted ( 'command_id' ) ; $ selected = $ this -> getPosted ( 'selected' , array ( ) , false , 'array' ) ; if ( $ command_id && $ selected ) { $ limit = 100 ; $ save = array_slice ( array_unique ( $ selected ) , 0 , $ limit ) ; $ this -> session -> set ( 'file_manager_selected' , $ save ) ; $ query = array ( 'cmd' => $ command_id , 'path' => $ this -> data_path , 'selected' => true ) ; $ this -> url -> redirect ( '' , $ query ) ; } $ this -> redirect ( ) ; }
|
Handles submitted selected items
|
56,509
|
protected function submitCommandFileManager ( ) { $ result = $ this -> command -> submit ( $ this -> data_command , array ( $ this ) ) ; $ this -> setMessageFileManager ( $ result [ 'message' ] , $ result [ 'severity' ] , true ) ; $ this -> session -> delete ( 'file_manager_selected' ) ; $ this -> redirect ( $ result [ 'redirect' ] ) ; }
|
Process the current command
|
56,510
|
protected function getTabsFileManager ( ) { $ commands = $ this -> command -> getAllowed ( $ this -> data_file ) ; if ( ! empty ( $ this -> data_selected ) && $ this -> isQuery ( 'selected' ) ) { $ commands [ $ this -> data_command [ 'command_id' ] ] = $ this -> data_command ; } $ tabs = array ( ) ; foreach ( $ commands as $ command_id => $ command ) { if ( ! isset ( $ command [ 'tab' ] ) || ! $ this -> access ( "module_file_manager_$command_id" ) ) { continue ; } $ tabs [ $ command [ 'tab' ] ] = array ( 'text' => $ this -> text ( $ command [ 'tab' ] ) , 'url' => $ this -> url ( '' , array ( 'path' => $ this -> data_path , 'cmd' => $ command_id ) ) , ) ; } return $ tabs ; }
|
Returns an array of allowed tabs for the current command
|
56,511
|
protected function getActionsFileManager ( ) { $ commands = $ this -> command -> getHandlers ( ) ; foreach ( $ commands as $ command_id => $ command ) { if ( empty ( $ command [ 'multiple' ] ) ) { unset ( $ commands [ $ command_id ] ) ; } } return $ commands ; }
|
Returns an array of commands that support multiple selection
|
56,512
|
protected function setBreadcrumbFileManager ( ) { $ breadcrumbs = array ( ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin' ) , 'text' => $ this -> text ( 'Dashboard' ) ) ; $ breadcrumbs [ ] = array ( 'url' => $ this -> url ( 'admin/tool' ) , 'text' => $ this -> text ( 'Tools' ) ) ; $ this -> setBreadcrumbs ( $ breadcrumbs ) ; }
|
Sets breadcrumbs on the file manager page
|
56,513
|
public function load ( ) { $ models = $ this -> loadRaw ( ) ; foreach ( $ models as & $ model ) { $ model = $ model -> getRepo ( ) -> getIdentityMap ( ) -> get ( $ model ) ; } return new RepoModels ( $ this -> getRepo ( ) , $ models ) ; }
|
Calls loadRaw and passes the result through an IdentityMap
|
56,514
|
public function loadWith ( array $ rels ) { $ models = $ this -> load ( ) ; $ this -> getRepo ( ) -> loadAllRelsFor ( $ models , $ rels , $ this -> flags ) ; return $ models ; }
|
Eager load relations .
|
56,515
|
protected function boot ( ) { if ( $ this -> booted ) { return ; } fire_callbacks ( $ this -> bootCallbacks , $ this ) ; $ this -> booted = true ; }
|
Set Tweech as booted Runs whenBooted callbacks .
|
56,516
|
public function whenBooted ( \ Closure $ callback ) { $ this -> bootCallbacks [ ] = $ callback ; if ( $ this -> isBooted ( ) ) { fire_callbacks ( [ $ callback ] , $ this ) ; } }
|
Run callbacks that are waiting for Tweech to boot .
|
56,517
|
protected function loadEventListeners ( ) { $ coreListeners = [ \ Raideer \ Tweech \ Listeners \ IrcMessageListener :: class , \ Raideer \ Tweech \ Listeners \ ChatMessageListener :: class , ] ; $ this [ 'client' ] -> registerEventListener ( $ coreListeners ) ; }
|
Loads Event Listeners .
|
56,518
|
public function saveApplicationPaths ( array $ paths ) { foreach ( $ paths as $ key => $ value ) { $ this -> applyInstance ( "path.$key" , realpath ( $ value ) ) ; } }
|
Saves application paths to the container .
|
56,519
|
public function addAttribute ( $ attributeName , $ value ) { if ( in_array ( $ attributeName , $ this -> lockedAttributes ) === true ) throw new FormHandlerException ( 'The attribute ' . $ attributeName . ' is within the locked attributes for this renderer' ) ; $ this -> attributes [ $ attributeName ] = $ value ; }
|
Adds an attribute and its value
|
56,520
|
public function addAttributes ( array $ attributes ) { foreach ( $ attributes as $ attrName => $ attrValue ) { $ this -> addAttribute ( $ attrName , $ attrValue ) ; } }
|
Adds multiple attributes and overwrites existing ones
|
56,521
|
public function removeAttribute ( $ attributeName ) { if ( array_key_exists ( $ attributeName , $ this -> attributes ) === false || in_array ( $ attributeName , $ this -> lockedAttributes ) === true ) return ; unset ( $ this -> attributes [ $ attributeName ] ) ; }
|
Removes an attribute from the attribute list
|
56,522
|
protected function getAttributesAsHtml ( ) { $ htmlAttrs = '' ; foreach ( $ this -> attributes as $ attrName => $ attrValue ) { $ htmlAttrs .= ' ' . $ attrName . ( ( $ attrValue === null || strlen ( $ attrValue ) === 0 ) ? null : '="' . $ attrValue . '"' ) ; } return $ htmlAttrs ; }
|
Returns a string with all attributes and their values in a valid HTML representation
|
56,523
|
private function parseParameters ( RequestInterface $ request ) : array { $ parameters = [ ] ; $ versionHeaders = $ request -> getHeader ( self :: API_VERSION_HEADER ) ; $ groupHeaders = $ request -> getHeader ( self :: API_GROUPS_HEADER ) ; $ versionHeader = reset ( $ versionHeaders ) ; $ groupHeader = reset ( $ groupHeaders ) ; if ( preg_match ( self :: API_VERSION_REGEXP , $ versionHeader , $ matches ) ) { $ parameters [ 'serialization_version' ] = $ matches [ 'version' ] ; } if ( preg_match ( self :: API_GROUPS_REGEXP , $ groupHeader , $ matches ) ) { $ parameters [ 'serialization_groups' ] = array_map ( 'trim' , explode ( ',' , $ matches [ 'groups' ] ) ) ; } return array_merge ( $ request -> get ( '_borobudur' , [ ] ) , $ parameters ) ; }
|
Parse the parameter with given request .
|
56,524
|
public function scopeCast ( $ query , Caster $ caster = null ) { $ caster = $ caster ? : $ this -> findCaster ( ) ; if ( $ this -> exists ) { return $ caster -> cast ( $ this ) ; } return $ caster -> cast ( $ query -> get ( ) ) ; }
|
Casts either a collection or a single model .
|
56,525
|
public function buildNotifications ( MessageInterface $ message ) { $ notifications = new \ ArrayIterator ( ) ; $ recipientQueue = new \ SplQueue ( ) ; $ recipientChunk = new \ ArrayIterator ( ) ; foreach ( $ message -> getRecipientDeviceCollection ( ) as $ recipient ) { $ recipientChunk -> append ( $ recipient ) ; if ( $ recipientChunk -> count ( ) >= $ message -> getMaxRecipientsPerMessage ( ) ) { $ recipientQueue -> enqueue ( $ recipientChunk ) ; $ recipientChunk = new \ ArrayIterator ( ) ; } } if ( $ recipientChunk -> count ( ) ) { $ recipientQueue -> enqueue ( $ recipientChunk ) ; } while ( ! $ recipientQueue -> isEmpty ( ) ) { $ notification = $ this -> createNotification ( $ recipientQueue -> dequeue ( ) , $ message ) ; $ notifications -> append ( $ notification ) ; } return $ notifications ; }
|
Generates number of notifications by message recipient count and notification service limitations
|
56,526
|
private function createNotification ( \ ArrayIterator $ recipients , MessageInterface $ message ) { $ message = clone $ message ; $ message -> setRecipientDeviceCollection ( $ recipients ) ; $ handlers = $ this -> getPayloadHandlers ( ) ; foreach ( $ handlers as $ handler ) { if ( $ handler -> isSupported ( $ message ) ) { $ notificationId = uniqid ( ) ; $ handler -> setNotificationId ( $ notificationId ) -> setMessage ( $ message ) ; $ packedPayload = $ this -> handlePayload ( $ handler ) ; $ customData = $ handler -> getCustomNotificationData ( ) ; $ notification = new Notification ( ) ; $ notification -> setIdentifier ( $ notificationId ) -> setType ( $ message -> getMessageType ( ) ) -> setRecipients ( $ recipients ) -> setPayload ( $ packedPayload ) -> setCustomNotificationData ( $ customData ) ; return $ notification ; } } throw new DomainException ( sprintf ( 'Unhandled message type %s' , $ message -> getMessageType ( ) ) ) ; }
|
Returns created notification
|
56,527
|
private function rebuildNode ( \ SimpleXMLElement $ nodeConfig , $ idPrefix ) { foreach ( $ nodeConfig as $ nodeName => $ node ) { $ nodeId = ( string ) @ $ node [ 'id' ] ; if ( in_array ( $ nodeName , $ this -> processorsNodeNames ) && ! $ nodeId ) { $ autoGeneratedId = $ idPrefix . '.' . $ this -> rebuiltNodesCounter ++ ; if ( $ this -> getContainer ( ) -> has ( $ autoGeneratedId ) ) { throw new InvalidConfigurationException ( 'Itinerary name used twice: ' . $ autoGeneratedId ) ; } $ node -> addAttribute ( 'id' , $ autoGeneratedId ) ; } $ this -> rebuildNode ( $ node , $ idPrefix ) ; } }
|
This method takes object and modifies it .
|
56,528
|
public function GetOAuthHeader ( $ url ) { $ signatureMethod = new OAuthSignatureMethod_HMAC_SHA1 ( ) ; $ request = OAuthRequest :: from_consumer_and_token ( $ this -> consumer , $ this -> token , 'POST' , $ url , array ( ) ) ; $ request -> sign_request ( $ signatureMethod , $ this -> consumer , $ this -> token ) ; $ header = $ request -> to_header ( ) ; $ pieces = explode ( ':' , $ header , 2 ) ; return trim ( $ pieces [ 1 ] ) ; }
|
Returns the value of the OAuth Authorization HTTP header for a given endpoint URL .
|
56,529
|
private function parseLinks ( $ text ) { $ offset = 0 ; $ matches = array ( ) ; while ( preg_match ( $ this -> links_pattern , $ text , $ matches , 0 , $ offset ) ) { switch ( $ matches [ 2 ] ) { case '->' : $ this -> links [ ] = array ( 'text' => trim ( $ matches [ 1 ] ) , 'link' => trim ( $ matches [ 3 ] ) ) ; $ this -> raw_links [ ] = $ matches [ 0 ] ; break ; case '<-' : case '|' : $ this -> links [ ] = array ( 'text' => trim ( $ matches [ 3 ] ) , 'link' => trim ( $ matches [ 1 ] ) ) ; $ this -> raw_links [ ] = $ matches [ 0 ] ; break ; default : throw new \ RuntimeException ( "Something that looked like a link could not be parsed." ) ; } $ offset = mb_stripos ( $ text , $ matches [ 0 ] ) + mb_strlen ( $ matches [ 0 ] ) ; } }
|
Parse all links for the given text passage based on the pattern for Twee
|
56,530
|
public function getImportersForContext ( $ all = false ) { $ importers = [ ] ; foreach ( $ this -> configuration -> getImporters ( $ all ) as $ key => $ importer ) { if ( $ importer -> supports ( $ this -> configuration ) ) { $ importers [ ] = $ importer ; } } return $ importers ; }
|
Returns importers keyed by their internal segment key .
|
56,531
|
private function persisterMethod ( $ method ) { $ processed = [ ] ; foreach ( $ this -> getImportersForContext ( ) as $ importer ) { $ persister = $ importer -> getPersister ( ) ; foreach ( $ processed as $ class ) { if ( $ persister instanceof $ class ) { continue 2 ; } } $ importer -> getPersister ( ) -> $ method ( ) ; $ processed [ ] = get_class ( $ persister ) ; } }
|
Executes the supplied method on each unique enabled persister .
|
56,532
|
private function renderPage ( Page $ page , Request $ request ) { return $ this -> get ( 'synapse' ) -> createDecorator ( $ page ) -> decorate ( array ( 'page' => $ page , 'request' => $ request , ) ) ; }
|
Call Synapse to render given page .
|
56,533
|
public function previewAction ( $ id , Request $ request ) { if ( ! $ page = $ this -> get ( 'synapse.page.loader' ) -> retrieve ( $ id ) ) { throw new NotFoundHttpException ( sprintf ( '"Page#%s" not found.' , $ id ) ) ; } return $ this -> renderPage ( $ page , $ request ) ; }
|
Page preview action .
|
56,534
|
public function renderAction ( $ path , Request $ request ) { if ( ! $ page = $ this -> get ( 'synapse.page.loader' ) -> retrieveByPath ( $ path , true ) ) { throw new NotFoundHttpException ( sprintf ( 'No online page found at path "%s".' , $ path ) ) ; } return $ this -> renderPage ( $ page , $ request ) ; }
|
Page rendering action .
|
56,535
|
protected function getLoader ( string $ path ) : LoaderInterface { if ( null === $ this -> loaderClass ) { throw new RuntimeException ( 'You must implement ' . __METHOD__ . ' or pass the loader class to the constructor' ) ; } return new $ this -> loaderClass ( $ path ) ; }
|
Create an instance of LoaderInterface for the path .
|
56,536
|
public function box ( $ id ) { if ( ! $ this -> has ( $ id ) ) { throw new Cargo \ Exception \ NotFoundException ( "Box '$id' was not defined." ) ; } return $ this -> boxes [ $ id ] ; }
|
get the box for this service
|
56,537
|
protected function renderItems ( $ items ) { $ script = '' ; foreach ( $ items as $ key => $ item ) { if ( is_array ( $ item ) ) { $ script = $ script . "'$key':[" ; foreach ( $ item as $ value ) $ script = $ script . "'$value'," ; $ script = $ script . "]," ; } else $ script = $ script . "'$key':'$item'," ; } return $ script ; }
|
Renders the items .
|
56,538
|
public function resolve ( VariationContext $ variationContext ) { $ variationContext = $ this -> variationProviderCollection -> reduce ( function ( VariationContext $ context , VariationProviderInterface $ variationProvider ) { return $ variationProvider -> hydrateContext ( $ context ) ? : $ context ; } , $ variationContext ) ; if ( empty ( $ variationContext -> theme ) ) { throw new \ InvalidArgumentException ( 'Current theme name is required into context under "theme" key.' ) ; } $ variationNamespace = $ variationContext -> theme ; unset ( $ variationContext -> theme ) ; $ variationConfig = array ( ) ; foreach ( $ this -> variationConfigs -> get ( $ variationNamespace ) as $ namespace => $ elements ) { $ variationConfig [ $ namespace ] = array ( ) ; foreach ( $ elements as $ element => $ config ) { $ variationConfig [ $ namespace ] [ $ element ] = array_diff_key ( $ config , array ( 'variations' => true ) ) ; if ( empty ( $ config [ 'variations' ] ) ) { continue ; } $ elementConfig = & $ variationConfig [ $ namespace ] [ $ element ] ; foreach ( $ config [ 'variations' ] as $ elementVariationConfig ) { if ( $ this -> expressionParser -> evaluate ( $ elementVariationConfig [ '_if' ] , $ variationContext -> normalize ( ) ) ) { $ elementConfig = array_replace_recursive ( $ elementConfig , $ elementVariationConfig [ '_then' ] ) ; if ( ! empty ( $ elementVariationConfig [ '_last' ] ) ) { break ; } } } } } return new Variation ( $ variationConfig , $ this -> propertyAccessor ) ; }
|
Create and resolve a variation from given context .
|
56,539
|
public static function parseHttpDate ( $ dateHeader ) { $ month = '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)' ; $ weekday = '(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday)' ; $ wkday = '(Mon|Tue|Wed|Thu|Fri|Sat|Sun)' ; $ time = '[0-2]\d(\:[0-5]\d){2}' ; $ date3 = $ month . ' ([1-3]\d| \d)' ; $ date2 = '[0-3]\d\-' . $ month . '\-\d\d' ; $ date1 = '[0-3]\d ' . $ month . ' [1-9]\d{3}' ; $ asctimeDate = $ wkday . ' ' . $ date3 . ' ' . $ time . ' [1-9]\d{3}' ; $ rfc850Date = $ weekday . ', ' . $ date2 . ' ' . $ time . ' GMT' ; $ rfc1123Date = $ wkday . ', ' . $ date1 . ' ' . $ time . ' GMT' ; $ httpDate = "($rfc1123Date|$rfc850Date|$asctimeDate)" ; $ dateHeader = trim ( $ dateHeader , ' ' ) ; if ( ! preg_match ( '/^' . $ httpDate . '$/' , $ dateHeader ) ) return false ; if ( strpos ( $ dateHeader , ' GMT' ) === false ) $ dateHeader .= ' GMT' ; $ realDate = strtotime ( $ dateHeader ) ; if ( $ realDate !== false && $ realDate >= 0 ) return new \ DateTime ( '@' . $ realDate , new DateTimeZone ( 'UTC' ) ) ; }
|
Parses a RFC2616 - compatible date string
|
56,540
|
public static function toHttpDate ( \ DateTime $ dateTime ) { $ dateTime = clone $ dateTime ; $ dateTime -> setTimeZone ( new \ DateTimeZone ( 'GMT' ) ) ; return $ dateTime -> format ( 'D, d M Y H:i:s \G\M\T' ) ; }
|
Transforms a DateTime object to HTTP s most common date format .
|
56,541
|
protected function getAttribute ( String $ attribute ) { if ( ! is_object ( $ this -> column ) ) { return null ; } if ( is_object ( $ this -> column ) && isset ( $ this -> column -> $ attribute ) ) { return $ this -> column -> $ attribute ; } if ( is_array ( $ this -> column ) && isset ( $ this -> column [ $ attribute ] ) ) { return $ this -> column [ $ attribute ] ; } }
|
Resolve column object and return attribute .
|
56,542
|
public function Contains ( $ path = '' , $ media = 'all' , $ doNotMinify = FALSE ) { $ result = FALSE ; $ linksGroup = & $ this -> _getLinksGroupContainer ( $ this -> actualGroupName ) ; foreach ( $ linksGroup as & $ item ) { if ( $ item -> path == $ path ) { if ( $ item -> media == $ media && $ item -> doNotMinify == $ doNotMinify ) { $ result = TRUE ; break ; } } } return $ result ; }
|
Check if style sheet is already presented in stylesheets group
|
56,543
|
public function AppendRendered ( $ path = '' , $ media = 'all' , $ doNotMinify = FALSE ) { return $ this -> Append ( $ path , $ media , TRUE , $ doNotMinify ) ; }
|
Append style sheet after all group stylesheets for later render process with php tags executing in given file
|
56,544
|
public function PrependRendered ( $ path = '' , $ media = 'all' , $ doNotMinify = FALSE ) { return $ this -> Prepend ( $ path , $ media , TRUE , $ doNotMinify ) ; }
|
Prepend style sheet before all group stylesheets for later render process with php tags executing in given file
|
56,545
|
public function OffsetSetRendered ( $ index = 0 , $ path = '' , $ media = 'all' , $ doNotMinify = FALSE ) { return $ this -> OffsetSet ( $ index , $ path , $ media , TRUE , $ doNotMinify ) ; }
|
Add style sheet into given index of stylesheets group array for later render process with php tags executing in given file
|
56,546
|
public function Append ( $ path = '' , $ media = 'all' , $ renderPhpTags = FALSE , $ doNotMinify = FALSE ) { $ item = $ this -> _completeItem ( $ path , $ media , $ renderPhpTags , $ doNotMinify ) ; $ currentGroupRecords = & $ this -> _getLinksGroupContainer ( $ this -> actualGroupName ) ; array_push ( $ currentGroupRecords , $ item ) ; return $ this ; }
|
Append style sheet after all group stylesheets for later render process
|
56,547
|
public function Prepend ( $ path = '' , $ media = 'all' , $ renderPhpTags = FALSE , $ doNotMinify = FALSE ) { $ item = $ this -> _completeItem ( $ path , $ media , $ renderPhpTags , $ doNotMinify ) ; $ currentGroupRecords = & $ this -> _getLinksGroupContainer ( $ this -> actualGroupName ) ; array_unshift ( $ currentGroupRecords , $ item ) ; return $ this ; }
|
Prepend style sheet before all group stylesheets for later render process
|
56,548
|
public function OffsetSet ( $ index = 0 , $ path = '' , $ media = 'all' , $ renderPhpTags = FALSE , $ doNotMinify = FALSE ) { $ item = $ this -> _completeItem ( $ path , $ media , $ renderPhpTags , $ doNotMinify ) ; $ currentGroupRecords = & $ this -> _getLinksGroupContainer ( $ this -> actualGroupName ) ; $ newItems = [ ] ; $ added = FALSE ; foreach ( $ currentGroupRecords as $ key => $ groupItem ) { if ( $ key == $ index ) { $ newItems [ ] = $ item ; $ added = TRUE ; } $ newItems [ ] = $ groupItem ; } if ( ! $ added ) $ newItems [ ] = $ item ; self :: $ linksGroupContainer [ $ this -> getCtrlActionKey ( ) ] [ $ this -> actualGroupName ] = $ newItems ; return $ this ; }
|
Add style sheet into given index of group stylesheets array for later render process
|
56,549
|
private function _isDuplicateStylesheet ( $ path ) { $ result = '' ; $ currentRecords = self :: $ linksGroupContainer [ $ this -> getCtrlActionKey ( ) ] ; foreach ( $ currentRecords as $ groupName => $ groupItems ) { foreach ( $ groupItems as $ item ) { if ( $ item -> path == $ path ) { $ result = $ groupName ; break ; } } } return $ result ; }
|
Is the linked style sheet duplicate?
|
56,550
|
public function Render ( $ indent = 0 ) { $ currentGroupRecords = & $ this -> _getLinksGroupContainer ( $ this -> actualGroupName ) ; if ( count ( $ currentGroupRecords ) === 0 ) return '' ; $ minify = ( bool ) self :: $ globalOptions [ 'cssMinify' ] ; $ joinTogether = ( bool ) self :: $ globalOptions [ 'cssJoin' ] ; if ( $ joinTogether ) { $ result = $ this -> _renderItemsTogether ( $ this -> actualGroupName , $ currentGroupRecords , $ indent , $ minify ) ; } else { $ result = $ this -> _renderItemsSeparated ( $ this -> actualGroupName , $ currentGroupRecords , $ indent , $ minify ) ; } return $ result ; }
|
Render link elements as html code with links to original files or temporary rendered files .
|
56,551
|
private function _minify ( & $ css , $ path ) { $ result = '' ; if ( ! is_callable ( static :: $ MinifyCallable ) ) { $ this -> exception ( "Configured callable object for CSS minification doesn't exist. " . 'Use: https://github.com/mrclay/minify -> /min/lib/Minify/CSS.php' ) ; } try { $ result = call_user_func ( static :: $ MinifyCallable , $ css ) ; } catch ( \ Exception $ e ) { $ this -> exception ( "Unable to minify style sheet ('$path')." ) ; } return $ result ; }
|
Minify style sheet string and return minified result .
|
56,552
|
private function _renderItemsTogetherAsGroup ( $ itemsToRender = [ ] , $ minify = FALSE ) { $ filesGroupInfo = [ ] ; foreach ( $ itemsToRender as $ item ) { if ( self :: $ fileChecking ) { $ fullPath = $ this -> getAppRoot ( ) . $ item -> path ; if ( ! file_exists ( $ fullPath ) ) { $ this -> exception ( "File not found in CSS view rendering process ('$fullPath')." ) ; } $ filesGroupInfo [ ] = $ item -> path . '?_' . self :: getFileImprint ( $ fullPath ) ; } else { $ filesGroupInfo [ ] = $ item -> path ; } } $ tmpFileFullPath = $ this -> getTmpFileFullPathByPartFilesInfo ( $ filesGroupInfo , $ minify , 'css' ) ; if ( self :: $ fileRendering ) { if ( ! file_exists ( $ tmpFileFullPath ) ) { $ resultContent = '' ; foreach ( $ itemsToRender as & $ item ) { $ srcFileFullPath = $ this -> getAppRoot ( ) . $ item -> path ; if ( $ item -> render ) { $ fileContent = $ this -> _renderFile ( $ srcFileFullPath ) ; } else if ( $ minify ) { $ fileContent = file_get_contents ( $ srcFileFullPath ) ; } $ fileContent = $ this -> _convertStylesheetPathsFromRelatives2TmpAbsolutes ( $ fileContent , $ item -> path ) ; if ( $ minify ) $ fileContent = $ this -> _minify ( $ fileContent , $ item -> path ) ; $ resultContent .= PHP_EOL . "/* " . $ item -> path . " */" . PHP_EOL . $ fileContent . PHP_EOL ; } $ this -> saveFileContent ( $ tmpFileFullPath , $ resultContent ) ; $ this -> log ( "Css files group rendered ('$tmpFileFullPath')." , 'debug' ) ; } } $ firstItem = array_merge ( ( array ) $ itemsToRender [ 0 ] , [ ] ) ; $ pathToTmp = substr ( $ tmpFileFullPath , strlen ( $ this -> getAppRoot ( ) ) ) ; $ firstItem [ 'href' ] = $ this -> CssJsFileUrl ( $ pathToTmp ) ; return $ this -> _renderItemSeparated ( ( object ) $ firstItem ) ; }
|
Render all items in group together when application is compiled do not check source files and changes .
|
56,553
|
private function _renderFile ( $ absolutePath ) { ob_start ( ) ; try { include ( $ absolutePath ) ; } catch ( \ Exception $ e ) { $ this -> exceptionHandler ( $ e ) ; } return ob_get_clean ( ) ; }
|
Render css file by absolute path as php file and return rendered result as string
|
56,554
|
private function _renderFileToTmpAndGetNewHref ( $ item , $ minify = FALSE ) { $ path = $ item -> path ; $ tmpFileName = '/rendered_css_' . self :: $ systemConfigHash . '_' . trim ( str_replace ( '/' , '_' , $ path ) , "_" ) ; $ srcFileFullPath = $ this -> getAppRoot ( ) . $ path ; $ tmpFileFullPath = $ this -> getTmpDir ( ) . $ tmpFileName ; if ( self :: $ fileRendering ) { if ( file_exists ( $ srcFileFullPath ) ) { $ srcFileModDate = filemtime ( $ srcFileFullPath ) ; } else { $ srcFileModDate = 1 ; } if ( file_exists ( $ tmpFileFullPath ) ) { $ tmpFileModDate = filemtime ( $ tmpFileFullPath ) ; } else { $ tmpFileModDate = 0 ; } if ( $ srcFileModDate !== FALSE && $ tmpFileModDate !== FALSE ) { if ( $ srcFileModDate > $ tmpFileModDate ) { if ( $ item -> render ) { $ fileContent = $ this -> _renderFile ( $ srcFileFullPath ) ; } else if ( $ minify ) { $ fileContent = file_get_contents ( $ srcFileFullPath ) ; } $ fileContent = $ this -> _convertStylesheetPathsFromRelatives2TmpAbsolutes ( $ fileContent , $ path ) ; if ( $ minify ) $ fileContent = $ this -> _minify ( $ fileContent , $ item -> path ) ; $ this -> saveFileContent ( $ tmpFileFullPath , $ fileContent ) ; $ this -> log ( "Css file rendered ('$tmpFileFullPath')." , 'debug' ) ; } } } $ tmpPath = substr ( $ tmpFileFullPath , strlen ( $ this -> getAppRoot ( ) ) ) ; return $ tmpPath ; }
|
Render css file by path as php file and store result in tmp directory and return new href value
|
56,555
|
protected function applyDependencies ( $ sources , \ Traversable $ dependencies , callable $ insert ) { foreach ( $ dependencies as $ query => $ subDependencies ) { $ joinedCode = '' ; foreach ( $ subDependencies as $ file ) { $ joinedCode .= $ insert ( $ file ) ; } $ sources = str_replace ( $ query , $ joinedCode , $ sources ) ; } return $ sources ; }
|
Inject dependencies inside code
|
56,556
|
public function convertToClassName ( $ table , $ namespace = 'Sonic\\Model\\' ) { $ arr = explode ( '_' , $ table ) ; foreach ( $ arr as & $ val ) { $ val = ucfirst ( strtolower ( $ val ) ) ; } return $ namespace . implode ( '\\' , $ arr ) ; }
|
Convert a table name class name
|
56,557
|
public function convertToNamespaceAndClass ( $ table ) { $ arr = explode ( '_' , $ table ) ; foreach ( $ arr as & $ val ) { $ val = ucfirst ( strtolower ( $ val ) ) ; } array_unshift ( $ arr , 'Sonic' , 'Model' ) ; $ class = array_pop ( $ arr ) ; $ namespace = implode ( '\\' , $ arr ) ; return array ( $ namespace , $ class ) ; }
|
Convert a table name to a namespace and class name
|
56,558
|
public static function _convertToUnixtime ( $ str ) { $ unixtime = 0 ; if ( preg_match ( '/^(\d{4})\D{1}(\d{2})\D{1}(\d{2}) (\d{2}):(\d{2}):(\d{2})$/' , $ str , $ matches ) ) { $ unixtime = mktime ( $ matches [ 4 ] , $ matches [ 5 ] , $ matches [ 6 ] , $ matches [ 2 ] , $ matches [ 3 ] , $ matches [ 1 ] ) ; } else if ( preg_match ( '/^(\d{4})\D{1}(\d{2})\D{1}(\d{2})$/' , $ str , $ matches ) ) { $ unixtime = mktime ( 0 , 0 , 0 , $ matches [ 2 ] , $ matches [ 3 ] , $ matches [ 1 ] ) ; } else if ( preg_match ( '/^(\d{2})\D{1}(\d{2})\D{1}(\d{4}) (\d{2}):(\d{2}):(\d{2})$/' , $ str , $ matches ) ) { $ unixtime = mktime ( $ matches [ 4 ] , $ matches [ 5 ] , $ matches [ 6 ] , $ matches [ 2 ] , $ matches [ 1 ] , $ matches [ 3 ] ) ; } else if ( preg_match ( '/^(\d{2})\D{1}(\d{2})\D{1}(\d{4})$/' , $ str , $ matches ) ) { $ unixtime = mktime ( 0 , 0 , 0 , $ matches [ 2 ] , $ matches [ 1 ] , $ matches [ 3 ] ) ; } else if ( preg_match ( '/^\d+$/' , $ str ) ) { $ unixtime = $ str ; } return $ unixtime ; }
|
Convert a date or datetime into a unix timestamp
|
56,559
|
public static function _utcDate ( $ format = 'Y-m-d H:i:s' , $ time = FALSE ) { return $ time ? gmdate ( $ format , $ time ) : gmdate ( $ format ) ; }
|
Return a UTC date
|
56,560
|
public static function _convertTZ ( $ date , $ to , $ format = 'Y-m-d H:i:s' , $ from = 'UTC' ) { $ date = new \ DateTime ( $ date , new \ DateTimeZone ( $ from ) ) ; $ date -> setTimezone ( new \ DateTimeZone ( $ to ) ) ; return $ date -> format ( $ format ) ; }
|
Convert a date between timezones
|
56,561
|
public static function _ak ( $ arr , $ key , $ fallback = NULL ) { return self :: ak ( $ arr , $ key , $ fallback ) ; }
|
Returns the value of the key of the passed array if it exists or null if not This saves having to explictly declare each array key to check that they exist
|
56,562
|
final protected function writeln ( $ text , $ breakAfter = false , $ breakBefore = false ) { $ indent = ( $ this -> indent > 0 ) ? $ this -> indent : 0 ; $ text = sprintf ( '%s%s' , str_repeat ( ' ' , 4 * $ indent ) , $ text ) ; if ( true === $ breakAfter ) { $ text = sprintf ( "%s\r\n" , $ text ) ; } if ( true == $ breakBefore ) { $ text = sprintf ( "\r\n%s" , $ text ) ; } $ this -> output -> writeln ( $ text ) ; }
|
Unified text output for extending classes . Writes lines in a standard way .
|
56,563
|
final protected function loop ( callable $ counter , callable $ retriever , callable $ modifier , callable $ persister , $ label = null , $ limit = 200 , $ skipStart = 0 ) { $ count = $ total = ( int ) $ counter ( ) - $ skipStart ; $ modified = $ index = 0 ; $ steps = ceil ( $ total / $ limit ) ; if ( 0 >= $ total ) { $ this -> writeln ( sprintf ( '<error>Nothing to process for %s!</error>' , $ label ) ) ; return ; } $ bar = $ this -> getProgressBar ( $ total , $ label ) ; $ this -> writeln ( '' , true , true ) ; $ bar -> start ( ) ; while ( $ count > 0 ) { $ skip = $ limit * $ index + $ skipStart ; $ items = $ retriever ( $ limit , $ skip ) ; $ formatted = [ ] ; foreach ( $ items as $ item ) { $ item = $ modifier ( $ item ) ; if ( null !== $ item ) { $ formatted [ ] = $ item ; } } $ persister ( $ formatted ) ; $ modified += count ( $ formatted ) ; $ index ++ ; $ count -= $ limit ; $ bar -> setMessage ( $ modified , 'modified' ) ; $ bar -> setProgress ( $ total - $ count ) ; } $ bar -> finish ( ) ; $ this -> writeln ( '' , true , true ) ; }
|
Generic loop iterator .
|
56,564
|
public function fieldChanged ( string $ field ) : bool { $ old = $ this -> getModel ( ) -> getOriginal ( $ field ) ; $ current = $ this -> getModel ( ) -> { $ field } ; return $ old != $ current ; }
|
Checks if the given field changed on the current model
|
56,565
|
public function assertIsNumericAndNonZero ( $ value , $ message = '%s must be a number and not 0' , $ exception = 'Asserts' ) { if ( is_numeric ( $ value ) === false || floatval ( $ value ) <= 0 ) { $ this -> throwException ( $ exception , $ message , $ value ) ; } }
|
Verifies that the specified condition is numeric and non zero . The assertion fails if the condition is not numeric or numeric less or equal zero .
|
56,566
|
public function createMessageId ( ) { return sprintf ( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x' , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0x0fff ) | 0x4000 , mt_rand ( 0 , 0x3fff ) | 0x8000 , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) , mt_rand ( 0 , 0xffff ) ) ; }
|
Create a random version 4 UUID
|
56,567
|
public function selectNMPdo ( $ request , $ param = null ) { $ statement = $ this -> getAdapter ( ) -> query ( $ request , ADT :: QUERY_MODE_PREPARE ) ; $ result = $ statement -> execute ( $ param ) ; $ resultSet = new ResultSet ( ) ; return $ resultSet -> initialize ( $ result ) ; }
|
Select whith PDO without mappage .
|
56,568
|
public function getPrimaryKey ( ) { if ( null === $ this -> primary ) { $ metadata = $ this -> getMetadata ( ) ; $ constraints = $ metadata -> getConstraints ( $ this -> getTable ( ) ) ; foreach ( $ constraints as $ constraint ) { if ( $ constraint -> getType ( ) == 'PRIMARY KEY' ) { $ this -> primary = $ constraint -> getColumns ( ) ; } } } return $ this -> primary ; }
|
Get Primary Keys .
|
56,569
|
public static function sortByTermResemblance ( array $ array , $ term ) { $ term = ( string ) s ( $ term ) -> toLowerCase ( ) ; usort ( $ array , function ( $ a , $ b ) use ( $ term ) { $ aScore = s ( $ a ) -> toLowerCase ( ) -> longestCommonPrefix ( $ term ) -> length ( ) ; $ bScore = s ( $ b ) -> toLowerCase ( ) -> longestCommonPrefix ( $ term ) -> length ( ) ; if ( $ aScore === $ bScore ) { return 0 ; } return $ aScore > $ bScore ? - 1 : 1 ; } ) ; return $ array ; }
|
Sorts an array in order of resemblance with the passed term .
|
56,570
|
public function loadConfig ( $ confFile ) { $ conf = $ this -> readConfig ( $ confFile ) ; try { foreach ( $ conf [ 'moduleConf' ] [ 'activeLoggers' ] as $ logger ) { $ tmpClass = new \ ReflectionClass ( '\\pff\\modules\\Utils\\' . ( string ) $ logger [ 'class' ] ) ; $ this -> _loggers [ ] = $ tmpClass -> newInstance ( ) ; } } catch ( \ ReflectionException $ e ) { throw new LoggerException ( 'Logger creation failed: ' . $ e -> getMessage ( ) ) ; } }
|
Loads the configuration
|
56,571
|
public static function getInstance ( $ confFile = 'logger/logger.conf.yaml' ) { if ( ! isset ( self :: $ _instance ) ) { $ className = __CLASS__ ; self :: $ _instance = new $ className ( $ confFile ) ; } return self :: $ _instance ; }
|
Returns a Logegr instance
|
56,572
|
public function log ( $ message , $ level = 0 ) { foreach ( $ this -> _loggers as $ logger ) { try { $ logger -> logMessage ( $ message , $ level ) ; } catch ( LoggerException $ e ) { throw $ e ; } } }
|
Main logging function . Logs a message with a level .
|
56,573
|
public function getHeader ( $ sName ) { $ sName = strtolower ( $ sName ) ; foreach ( $ this -> getAllHeaders ( ) as $ sKey => $ mValue ) { if ( strtolower ( $ sKey ) === $ sName ) { return $ mValue ; } } return null ; }
|
It returns the header by passed name . The search is case - insensitive .
|
56,574
|
public function getAllCookies ( ) { return filter_input_array ( \ INPUT_COOKIE , array_combine ( array_keys ( $ _COOKIE ) , array_fill ( 0 , count ( $ _COOKIE ) , \ FILTER_SANITIZE_STRING ) ) ) ; }
|
The method returns the associated array of cookies .
|
56,575
|
public function getUrlPath ( ) { $ sUri = $ this -> getServerParam ( 'REQUEST_URI' , \ FILTER_SANITIZE_URL ) ; if ( ! is_null ( $ sUri ) ) { return parse_url ( $ sUri , \ PHP_URL_PATH ) ; } return null ; }
|
It returns the URL path of the request .
|
56,576
|
protected function classMapFromPath ( $ subPath , $ namespace = null ) { $ messages = array ( ) ; $ classMap = $ this -> generator -> scan ( $ subPath , null , $ namespace , $ messages ) ; if ( $ messages ) { foreach ( $ messages as $ message ) { $ this -> report -> warn ( new GenericViolation ( $ message ) ) ; } } foreach ( $ classMap as $ class => $ file ) { try { $ this -> classMap -> add ( $ class , $ file ) ; } catch ( ClassAlreadyRegisteredException $ exception ) { $ this -> report -> append ( new ClassAddedMoreThanOnceViolation ( $ this -> getName ( ) , $ class , array ( $ exception -> getFileName ( ) , $ file ) ) ) ; } } return $ classMap ; }
|
Create a class map .
|
56,577
|
public function updateMetadata ( array $ metadata ) { $ processed = array ( ) ; foreach ( $ metadata as $ k => $ v ) { $ processed [ strtolower ( str_ireplace ( 'X-Container-Meta-' , '' , $ k ) ) ] = $ v ; } $ this -> connection -> makeRequest ( Client :: POST , array ( $ this -> name ) , $ processed ) ; $ this -> metadata = $ processed ; }
|
Updates container metadata .
|
56,578
|
public function enableStaticWeb ( $ index = null , $ enableListings = null , $ error = null , $ listingsCss = null ) { $ metadata = array ( 'X-Container-Meta-Web-Index' => '' , 'X-Container-Meta-Web-Listings' => '' , 'X-Container-Meta-Web-Error' => '' , 'X-Container-Meta-Web-Listings-CSS' => '' , ) ; if ( null !== $ index ) { $ metadata [ 'X-Container-Meta-Web-Index' ] = strval ( $ index ) ; } if ( null !== $ enableListings && is_bool ( $ enableListings ) ) { $ metadata [ 'X-Container-Meta-Web-Listings' ] = $ enableListings ? 'True' : 'False' ; } if ( null !== $ error ) { $ metadata [ 'X-Container-Meta-Web-Error' ] = strval ( $ error ) ; } if ( null !== $ listingsCss ) { $ metadata [ 'X-Container-Meta-Listings-CSS' ] = strval ( $ listingsCss ) ; } $ this -> updateMetadata ( $ metadata ) ; }
|
Enable static web for this container .
|
56,579
|
public function makePublic ( $ ttl = 86400 ) { if ( ! $ this -> connection -> getCdnEnabled ( ) ) { throw new Exceptions \ CDNNotEnabled ( ) ; } if ( $ this -> cdnUri ) { $ requestMethod = Client :: POST ; } else { $ requestMethod = Client :: PUT ; } $ response = $ this -> connection -> makeCdnRequest ( $ requestMethod , array ( $ this -> name ) , array ( 'X-TTL' => strval ( $ ttl ) , 'X-CDN-Enabled' => 'True' , 'Content-Length' => 0 , ) ) ; $ this -> cdnTtl = $ ttl ; $ this -> cdnUri = $ response [ 'headers' ] [ 'x-cdn-uri' ] ; $ this -> cdnSslUri = $ response [ 'headers' ] [ 'x-cdn-ssl-uri' ] ; }
|
Either publishes the current container to the CDN or updates its CDN attributes . Requires CDN be enabled on the account .
|
56,580
|
public function makePrivate ( ) { if ( ! $ this -> connection -> getCdnEnabled ( ) ) { throw new Exceptions \ CDNNotEnabled ( ) ; } $ this -> cdnUri = null ; $ this -> connection -> makeCdnRequest ( Client :: POST , array ( $ this -> name ) , array ( 'X-CDN-Enabled' => 'False' ) ) ; }
|
Disables CDN access to this container . It may continue to be available until its TTL expires .
|
56,581
|
public function purgeFromCdn ( $ email = null ) { if ( ! $ this -> connection -> getCdnEnabled ( ) ) { throw new Exceptions \ CDNNotEnabled ( ) ; } $ headers = array ( ) ; if ( null !== $ email ) { $ headers [ 'X-Purge-Email' ] = $ email ; } $ this -> connection -> makeCdnRequest ( Client :: DELETE , array ( $ this -> name ) , $ headers ) ; }
|
Purge Edge cache for all object inside of this container . You will be notified by email if one is provided when the job completes .
|
56,582
|
public function deleteObject ( $ name ) { if ( is_object ( $ name ) && $ name instanceof Object ) { $ name = $ name -> getName ( ) ; } $ this -> connection -> makeRequest ( Client :: DELETE , array ( $ this -> name , $ name ) ) ; }
|
Permanently remove a storage object .
|
56,583
|
public function getObjects ( array $ parameters = array ( ) ) { $ objects = array ( ) ; foreach ( $ this -> getObjectsInfo ( $ parameters ) as $ record ) { $ objects [ ] = new Object ( $ this , null , false , $ record ) ; } return $ objects ; }
|
Return array with objects of container .
|
56,584
|
protected function getObjectsRawData ( array $ parameters = array ( ) ) { $ cacheKey = md5 ( json_encode ( array ( $ this -> getName ( ) , $ parameters ) ) ) ; if ( ! array_key_exists ( $ cacheKey , self :: $ listObjectsCache ) ) { $ tmp = array ( ) ; foreach ( $ parameters as $ k => $ v ) { if ( in_array ( $ k , self :: $ allowedParameters ) ) { $ tmp [ $ k ] = $ v ; } } $ response = $ this -> connection -> makeRequest ( Client :: GET , array ( $ this -> name ) , array ( ) , $ tmp ) ; self :: $ listObjectsCache [ $ cacheKey ] = $ response [ 'body' ] ; } return self :: $ listObjectsCache [ $ cacheKey ] ; }
|
Return a raw response string with information about container objects .
|
56,585
|
public function fromUrl ( string $ requestUrl ) { return array_reduce ( $ this -> factories , function ( $ lead , LeadFactoryInterface $ factory ) use ( $ requestUrl ) { return $ lead ?? $ factory -> fromUrl ( $ requestUrl ) ; } ) ; }
|
Parse request url and create lead with common information
|
56,586
|
public function Exception ( $ exception ) { while ( ob_get_level ( ) ) { ob_end_clean ( ) ; } $ this -> result = array ( 'status' => 'fail' , 'message' => 'exception' , 'exception' => array ( 'file' => $ exception -> getFile ( ) , 'line' => $ exception -> getLine ( ) , 'message' => $ exception -> getMessage ( ) ) ) ; $ auditlog = \ Sonic \ Sonic :: getResource ( 'auditlog' ) ; if ( $ auditlog instanceof Audit \ Log ) { $ auditlog :: _Log ( $ this -> action , 7 , $ this -> args , $ this -> result [ 'exception' ] ) ; } $ this -> Display ( ) ; }
|
Deal with an api exception
|
56,587
|
public function callAction ( $ action = FALSE ) { $ this -> setRequestType ( ) ; $ this -> setArguments ( ) ; $ this -> setReturnType ( ) ; $ this -> Action ( $ action ) ; }
|
Wrapper function to complete an API request Set request type action arguments and response type . Call the action and then log .
|
56,588
|
public function setRequestType ( $ type = FALSE ) { if ( $ type !== FALSE ) { $ this -> requestType = $ type ; } else if ( isset ( $ _GET [ 'request_type' ] ) ) { $ this -> requestType = $ _GET [ 'request_type' ] ; } }
|
Set the API request type
|
56,589
|
public function setReturnType ( $ type = FALSE ) { if ( $ type !== FALSE ) { $ this -> returnType = $ type ; } else if ( isset ( $ this -> args [ 'return_type' ] ) ) { $ this -> returnType = $ this -> args [ 'return_type' ] ; } }
|
Set the API return type
|
56,590
|
public function Action ( $ strAction = FALSE ) { if ( $ strAction ) { $ this -> action = $ strAction ; } else if ( isset ( $ this -> args [ 'method' ] ) ) { $ this -> action = $ this -> args [ 'method' ] ; } $ auditlog = \ Sonic \ Sonic :: getResource ( 'auditlog' ) ; $ logType = 2 ; $ logParams = FALSE ; $ logResponse = FALSE ; $ arrAction = explode ( '.' , $ this -> action ) ; if ( count ( $ arrAction ) >= 2 ) { $ strMethod = array_pop ( $ arrAction ) ; $ strModule = implode ( '.' , $ arrAction ) ; $ objModule = $ this -> getModule ( $ strModule ) ; if ( $ objModule ) { if ( $ objModule -> checkMethod ( $ strMethod ) ) { if ( $ this -> checkLimitation ( $ strModule , $ strMethod ) ) { $ arrReturn = $ objModule -> callMethod ( $ this , $ strModule , $ strMethod , $ this -> args ) ; if ( $ arrReturn [ 'status' ] == 'ok' ) { $ this -> result [ 'status' ] = 'ok' ; unset ( $ arrReturn [ 'status' ] ) ; if ( $ arrReturn ) { $ this -> result [ $ strMethod ] = $ arrReturn ; } $ logType = 2 ; } else { foreach ( $ arrReturn as $ strKey => $ strVal ) { $ this -> result [ $ strKey ] = $ strVal ; } $ logType = 3 ; $ logParams = $ this -> args ; $ logResponse = @ $ this -> result [ 'message' ] ; } } else { $ this -> result [ 'status' ] = 'fail' ; $ this -> result [ 'message' ] = 'method access limited' ; $ logType = 11 ; } } else { $ this -> result [ 'status' ] = 'fail' ; $ this -> result [ 'message' ] = 'invalid method' ; $ logType = 10 ; } } else { $ this -> result [ 'status' ] = 'fail' ; $ this -> result [ 'message' ] = 'invalid module' ; $ logType = 9 ; } } else { $ this -> result [ 'status' ] = 'fail' ; $ this -> result [ 'message' ] = 'invalid action' ; $ logType = 8 ; } $ this -> result [ 'method' ] = $ this -> action ; $ this -> result [ 'request_type' ] = $ this -> requestType ; $ this -> result [ 'return_type' ] = $ this -> returnType ; if ( $ auditlog instanceof Audit \ Log ) { $ auditlog :: _Log ( $ this -> action , $ logType , $ logParams , $ logResponse ) ; } return TRUE ; }
|
Call an API action
|
56,591
|
public function getModule ( $ module ) { $ this -> getModules ( ) ; foreach ( $ this -> modules as $ obj ) { if ( strtolower ( $ obj -> get ( 'name' ) ) == $ module && class_exists ( $ obj -> getModuleClass ( ) ) ) { return $ obj ; } } return FALSE ; }
|
Return an API module object if it exists
|
56,592
|
public function checkLimitation ( $ module , $ method ) { if ( ! $ this -> actionLimit || ! Parser :: _ak ( $ this -> actionLimit , 'all' , TRUE ) ) { return FALSE ; } if ( Parser :: _ak ( $ this -> actionLimit , 'all' , FALSE ) ) { return TRUE ; } if ( Parser :: _ak ( $ this -> actionLimit , array ( $ module , $ method ) , FALSE ) ) { return TRUE ; } if ( Parser :: _ak ( $ this -> actionLimit , $ module , FALSE ) === TRUE ) { return TRUE ; } return FALSE ; }
|
Check whether a module method is limited
|
56,593
|
public function Display ( ) { header ( "Expires: Sun, 23 Nov 1984 03:13:37 GMT" ) ; header ( "Last-Modified: " . gmdate ( "D, d M Y H:i:s" ) . " GMT" ) ; header ( "Cache-Control: no-store, no-cache, must-revalidate" ) ; header ( "Cache-Control: post-check=0, pre-check=0" , FALSE ) ; header ( "Pragma: no-cache" ) ; if ( Parser :: _ak ( $ this -> result , 'authenticated' , FALSE ) !== 0 ) { unset ( $ this -> result [ 'auth_error' ] ) ; } switch ( $ this -> returnType ) { case 'xml' : header ( 'Content-Type: application/xml' ) ; echo $ this -> outputXML ( ) ; break ; case 'serialized' : header ( 'Content-Type: application/vnd.php.serialized' ) ; echo $ this -> outputSerialized ( ) ; break ; case 'extjs' : $ this -> result [ 'success' ] = $ this -> result [ 'status' ] == 'ok' ; unset ( $ this -> result [ 'status' ] ) ; header ( 'Content-Type: application/json' ) ; echo $ this -> outputJSON ( ) ; break ; case 'fileupload' : $ this -> result [ 'success' ] = $ this -> result [ 'status' ] == 'ok' ; unset ( $ this -> result [ 'status' ] ) ; header ( 'Content-Type: text/html' ) ; echo $ this -> outputJSON ( ) ; break ; case 'json' : default : header ( 'Content-Type: application/json' ) ; echo $ this -> outputJSON ( ) ; break ; } }
|
Display the API result
|
56,594
|
public function outputXML ( ) { $ doc = new \ DOMDocument ( '1.0' , 'UTF-8' ) ; $ xml = $ this -> generateXML ( $ doc ) ; $ doc -> appendChild ( $ xml ) ; return $ doc -> saveXML ( ) ; }
|
Return XML encoded result
|
56,595
|
public function generateXML ( & $ doc , $ arr = FALSE , $ xml = FALSE ) { if ( $ xml === FALSE ) { $ xml = $ doc -> createElement ( strtolower ( $ this -> rootNode ) ) ; } if ( $ arr === FALSE ) { $ arr = $ this -> result ; } foreach ( $ arr as $ key => $ val ) { if ( is_object ( $ val ) && is_numeric ( $ key ) ) { $ key = get_class ( $ val ) ; } else if ( is_array ( $ val ) && array_key_exists ( 'class' , $ val ) ) { $ key = $ val [ 'class' ] ; unset ( $ val [ 'class' ] ) ; } else if ( is_numeric ( $ key ) ) { $ key = 'result_' . $ key ; } $ element = $ doc -> createElement ( strtolower ( $ key ) ) ; if ( is_array ( $ val ) ) { $ element = $ this -> generateXML ( $ doc , $ val , $ element ) ; } else { $ element -> nodeValue = htmlentities ( $ val ) ; } $ xml -> appendChild ( $ element ) ; } return $ xml ; }
|
Generate XML from result
|
56,596
|
public static function getConnection ( $ id ) { if ( isset ( static :: $ connections [ $ id ] ) && ! is_object ( static :: $ connections [ $ id ] ) ) { unset ( static :: $ connections [ $ id ] ) ; } return isset ( static :: $ connections [ $ id ] ) ? static :: $ connections [ $ id ] : null ; }
|
get a Connection by id
|
56,597
|
protected function _clear ( ) { $ this -> selects = array ( ) ; $ this -> wheres = array ( ) ; $ this -> limit = 999999 ; $ this -> offset = 0 ; $ this -> sorts = array ( ) ; }
|
Resets the class variables to default settings
|
56,598
|
private function getPersisterFor ( $ scn ) { $ reflobj = new \ ReflectionObject ( $ this -> storageEngine ) ; $ accessor = $ reflobj -> getMethod ( 'getPersisterFor' ) ; $ accessor -> setAccessible ( true ) ; return $ accessor -> invoke ( $ this -> storageEngine , $ scn ) ; }
|
Uses reflection to get underlying Store persister .
|
56,599
|
private function extractRawModelValues ( $ scn , $ model ) { $ persister = $ this -> getPersisterFor ( $ scn ) ; $ reflobj = new \ ReflectionObject ( $ persister ) ; $ accessor = $ reflobj -> getMethod ( 'createInsertObj' ) ; $ accessor -> setAccessible ( true ) ; return $ accessor -> invoke ( $ persister , $ model ) ; }
|
Uses reflection to extract the raw model values from the Store s persister .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.