idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
5,600 | public static function initDatesInRange ( $ start_date , $ end_date , $ daysDifference = 1 ) { $ dates_in_range = [ ] ; $ begin = new DateTime ( $ start_date ) ; $ end = new DateTime ( $ end_date ) ; $ endModify = $ end -> modify ( '+' . $ daysDifference . ' day' ) ; $ interval = new DateInterval ( 'P' . $ daysDifferen... | Generate dates in range |
5,601 | public static function initDatetimesInRange ( $ start_datetime , $ end_datetime , $ hoursDifference = 1 ) { $ dates_in_range = [ ] ; $ begin = new DateTime ( $ start_datetime ) ; $ end = new DateTime ( $ end_datetime ) ; $ endModify = $ end -> modify ( '+' . $ hoursDifference . ' hour' ) ; $ interval = new DateInterval... | Generate datetimes in range |
5,602 | public static function get_cron ( $ controller , $ action ) { $ cron = self :: find ( ) -> where ( [ 'controller' => $ controller , 'action' => $ action , 'success' => 0 ] ) -> orderBy ( 'id_cron_job DESC' ) -> one ( ) ; if ( is_null ( $ cron ) ) { $ cron = new CronJob ( ) ; $ cron -> controller = $ controller ; $ cron... | Get a cron or generates a new one |
5,603 | public static function get_previous_cron ( $ controller , $ action ) { return self :: find ( ) -> where ( [ 'controller' => $ controller , 'action' => $ action , 'success' => 1 ] ) -> orderBy ( 'id_cron_job DESC' ) -> one ( ) ; } | Get previous successful ran cron |
5,604 | public static function run ( $ controller , $ action , $ limit , $ max ) { $ current = self :: get_cron ( $ controller , $ action ) ; $ current :: execution_time ( ) ; $ current -> limit = $ limit ; $ current -> running = 1 ; $ current -> success = 0 ; $ previous = self :: get_previous_cron ( $ controller , $ action ) ... | Starts a cron job |
5,605 | public function finish ( ) { $ this -> running = 0 ; $ this -> success = 1 ; $ this -> last_execution_time = self :: execution_time ( ) ; if ( $ this -> save ( ) ) { Console :: stdout ( Console :: ansiFormat ( "*** finished " . $ this -> controller . "/" . $ this -> action . " (time: " . sprintf ( "%.3f" , $ this -> la... | Ends a cron job |
5,606 | protected function setHeadersFromString ( $ rawHeaders ) { $ rawHeaders = str_replace ( "\r\n" , "\n" , $ rawHeaders ) ; $ headerCollection = explode ( "\n\n" , trim ( $ rawHeaders ) ) ; $ rawHeader = array_pop ( $ headerCollection ) ; $ headerComponents = explode ( "\n" , $ rawHeader ) ; foreach ( $ headerComponents a... | Parse the raw headers and set as an array . |
5,607 | function save ( ) { $ dirty_props = $ this -> _dirty ; if ( $ this -> _vars ) { $ dirty_vars = $ this -> _vars -> getDirtyVariables ( ) ; if ( $ dirty_vars ) { $ dirty_props [ 'vars' ] = $ dirty_vars ; } } $ this -> _api -> doRequest ( 'POST' , $ this -> getBaseApiPath ( ) , $ dirty_props ) ; $ this -> _dirty = array (... | Saves any updated properties to Telerivet . |
5,608 | public static function merge ( & $ article ) { if ( sizeof ( $ article -> textBlocks ) < 2 ) { return ; } $ previousBlock = null ; foreach ( $ article -> textBlocks as $ key => $ textBlock ) { if ( ! isset ( $ previousBlock ) ) { $ previousBlock = $ textBlock ; continue ; } if ( ! $ textBlock -> isContent ) { $ previou... | Executes this merger |
5,609 | public function getFieldset ( $ set = null ) { $ fields = array ( ) ; if ( $ set ) { $ elements = $ this -> findFieldsByFieldset ( $ set ) ; } else { $ elements = $ this -> findFieldsByGroup ( ) ; } if ( empty ( $ elements ) ) { return $ fields ; } foreach ( $ elements as $ element ) { $ attrs = $ element -> xpath ( 'a... | Method to get an array of Field objects in a given fieldset by name . If no name is given then all fields are returned . |
5,610 | public function setField ( \ SimpleXMLElement $ element , $ group = null , $ replace = true ) { if ( ! ( $ this -> xml instanceof \ SimpleXMLElement ) ) { throw new \ UnexpectedValueException ( sprintf ( '%s::setField `xml` is not an instance of SimpleXMLElement' , get_class ( $ this ) ) ) ; } $ old = $ this -> findFie... | Method to set a field XML element to the form definition . If the replace flag is set then the field will be set whether it already exists or not . If it isn t set then the field will not be replaced if it already exists . |
5,611 | public function setFieldAttribute ( $ name , $ attribute , $ value , $ group = null ) { if ( ! ( $ this -> xml instanceof \ SimpleXMLElement ) ) { throw new \ UnexpectedValueException ( sprintf ( '%s::setFieldAttribute `xml` is not an instance of SimpleXMLElement' , get_class ( $ this ) ) ) ; } $ element = $ this -> fi... | Method to set an attribute value for a field XML element . |
5,612 | public function validate ( $ data , $ group = null ) { if ( ! ( $ this -> xml instanceof \ SimpleXMLElement ) ) { return false ; } $ return = true ; $ input = new Registry ( $ data ) ; $ fields = $ this -> findFieldsByGroup ( $ group ) ; if ( ! $ fields ) { return false ; } foreach ( $ fields as $ field ) { $ value = n... | Method to validate form data . |
5,613 | protected function findField ( $ name , $ group = null ) { $ element = false ; $ fields = array ( ) ; if ( ! ( $ this -> xml instanceof \ SimpleXMLElement ) ) { return false ; } if ( $ group ) { $ elements = & $ this -> findGroup ( $ group ) ; foreach ( $ elements as $ element ) { if ( $ tmp = $ element -> xpath ( 'des... | Method to get a form field represented as an XML element object . |
5,614 | protected function & findGroup ( $ group ) { $ false = false ; $ groups = array ( ) ; $ tmp = array ( ) ; if ( ! ( $ this -> xml instanceof \ SimpleXMLElement ) ) { return $ false ; } $ group = explode ( '.' , $ group ) ; if ( ! empty ( $ group ) ) { $ elements = $ this -> xml -> xpath ( '//fields[@name="' . ( string )... | Method to get a form field group represented as an XML element object . |
5,615 | public function showBlocksFields ( ) { $ whiteList = $ this -> blockManager -> getWhiteListedPageTypes ( ) ; $ blackList = $ this -> blockManager -> getBlackListedPageTypes ( ) ; if ( in_array ( $ this -> owner -> ClassName , $ blackList ) ) { return false ; } if ( count ( $ whiteList ) && ! in_array ( $ this -> owner ... | Check if the Blocks CMSFields should be displayed for this Page |
5,616 | public function updateCMSFields ( FieldList $ fields ) { if ( $ fields -> fieldByName ( 'Root.Blocks' ) || ! $ this -> showBlocksFields ( ) ) { return ; } $ areas = $ this -> blockManager -> getAreasForPageType ( $ this -> owner -> ClassName ) ; if ( $ areas && count ( $ areas ) ) { $ fields -> addFieldToTab ( 'Root' ,... | Block manager for Pages . |
5,617 | public function BlockArea ( $ area , $ limit = null ) { if ( $ this -> owner -> ID <= 0 ) { return ; } $ list = $ this -> getBlockList ( $ area ) ; foreach ( $ list as $ block ) { if ( ! $ block -> canView ( ) ) { $ list -> remove ( $ block ) ; } } if ( $ limit !== null ) { $ list = $ list -> limit ( $ limit ) ; } $ da... | Called from templates to get rendered blocks for the given area . |
5,618 | public function getBlockList ( $ area = null , $ includeDisabled = false ) { $ includeSets = $ this -> blockManager -> getUseBlockSets ( ) && $ this -> owner -> InheritBlockSets ; $ blocks = ArrayList :: create ( ) ; $ nativeBlocks = $ this -> owner -> Blocks ( ) -> sort ( 'Sort' ) ; if ( $ area ) { $ nativeBlocks = $ ... | Get a merged list of all blocks on this page and ones inherited from BlockSets . |
5,619 | public function getAppliedSets ( ) { $ list = ArrayList :: create ( ) ; if ( ! $ this -> owner -> InheritBlockSets ) { return $ list ; } $ sets = BlockSet :: get ( ) -> where ( "(PageTypesValue IS NULL) OR (PageTypesValue LIKE '%:\"{$this->owner->ClassName}%')" ) ; $ ancestors = $ this -> owner -> getAncestors ( ) -> c... | Get Any BlockSets that apply to this page . |
5,620 | public function getBlocksFromAppliedBlockSets ( $ area = null , $ includeDisabled = false ) { $ blocks = ArrayList :: create ( ) ; $ sets = $ this -> getAppliedSets ( ) ; if ( ! $ sets -> count ( ) ) { return $ blocks ; } foreach ( $ sets as $ set ) { $ setBlocks = $ set -> Blocks ( ) -> sort ( 'Sort DESC' ) ; if ( ! $... | Get all Blocks from BlockSets that apply to this page . |
5,621 | public function request ( $ method , $ endpoint , array $ params = [ ] ) { return new DmmRequest ( $ this -> credential , $ method , $ endpoint , $ params ) ; } | Instantiates a new DmmRequest entity . |
5,622 | public function api ( $ name ) { switch ( $ name ) { case 'actress' : $ api = new Apis \ Actress ( $ this -> client , $ this -> credential ) ; break ; case 'author' : $ api = new Apis \ Author ( $ this -> client , $ this -> credential ) ; break ; case 'floor' : $ api = new Apis \ Floor ( $ this -> client , $ this -> cr... | Get API interface |
5,623 | public function parse ( $ data ) { $ result = array ( ) ; $ parts = explode ( "\n" , $ data ) ; foreach ( $ parts as $ index => $ part ) { $ kv = explode ( "=" , $ part ) ; if ( ! empty ( $ kv [ 1 ] ) ) { $ result [ $ kv [ 0 ] ] = $ kv [ 1 ] ; } } $ this -> load ( $ result ) ; } | Parse the return data from the request and load it into the object properties |
5,624 | public function getHash ( $ encode = false ) { $ hash = $ this -> h ; if ( substr ( $ hash , - 1 ) !== '=' ) { $ hash .= '=' ; } if ( $ encode === true ) { $ hash = str_replace ( '+' , '%2B' , $ hash ) ; } return $ hash ; } | Get the hash from the response |
5,625 | public function __isset ( $ name ) { if ( $ name == 'input' || $ name == 'label' ) { return true ; } if ( $ this -> $ name !== null ) { return true ; } return false ; } | Method to checks whether the value of certain inaccessible properties has been set or is it null . |
5,626 | public function fileGetContents ( $ url ) { $ rawResponse = file_get_contents ( $ url , false , $ this -> stream ) ; $ this -> responseHeaders = $ http_response_header ? : [ ] ; return $ rawResponse ; } | Send a stream wrapped request |
5,627 | public static function removeParamsFromUrl ( $ url , array $ paramsToFilter ) { $ parts = parse_url ( $ url ) ; $ query = '' ; if ( isset ( $ parts [ 'query' ] ) ) { $ params = [ ] ; parse_str ( $ parts [ 'query' ] , $ params ) ; foreach ( $ paramsToFilter as $ paramName ) { unset ( $ params [ $ paramName ] ) ; } if ( ... | Remove params from a URL . |
5,628 | public static function getParamsAsArray ( $ url ) { $ query = parse_url ( $ url , PHP_URL_QUERY ) ; if ( ! $ query ) { return [ ] ; } $ params = [ ] ; parse_str ( $ query , $ params ) ; return $ params ; } | Returns the params from a URL in the form of an array . |
5,629 | public function request ( \ Yubikey \ RequestCollection $ requests ) { $ responses = new \ Yubikey \ ResponseCollection ( ) ; $ startTime = microtime ( true ) ; $ multi = curl_multi_init ( ) ; $ curls = array ( ) ; foreach ( $ requests as $ index => $ request ) { $ curls [ $ index ] = curl_init ( ) ; curl_setopt_array ... | Make the request given the Request set and content |
5,630 | protected function getInput ( ) { $ html = array ( ) ; $ class = $ this -> element [ 'class' ] ? ' class="checkboxes ' . ( string ) $ this -> element [ 'class' ] . '"' : ' class="checkboxes"' ; $ checkedOptions = explode ( ',' , ( string ) $ this -> element [ 'checked' ] ) ; $ html [ ] = '<fieldset id="' . $ this -> id... | Method to get the field input markup for check boxes . |
5,631 | protected function getInput ( ) { $ size = $ this -> element [ 'size' ] ? ' size="' . ( int ) $ this -> element [ 'size' ] . '"' : '' ; $ maxLength = $ this -> element [ 'maxlength' ] ? ' maxlength="' . ( int ) $ this -> element [ 'maxlength' ] . '"' : '' ; $ class = $ this -> element [ 'class' ] ? ' class="' . ( strin... | Method to get the field input markup for password . |
5,632 | public static function create ( DmmResponse $ response ) { $ data = $ response -> getDecodedBody ( ) ; $ code = isset ( $ data [ 'status' ] ) ? $ data [ 'status' ] : null ; $ message = isset ( $ data [ 'message' ] ) ? $ data [ 'message' ] : 'Unknown error from API.' ; return new static ( $ response , new DmmOtherExcept... | A factory for creating the appropriate exception based on the response from API . |
5,633 | public function getPrefixes ( ) { $ prefixes = array ( ) ; foreach ( Mage :: helper ( 'ecomdev_varnish' ) -> getAllowedPages ( ) as $ name => $ label ) { $ prefixes [ ] = array ( 'field' => $ name . '_' , 'label' => $ label ) ; } return $ prefixes ; } | Get field prefixes for generating translation config nodes |
5,634 | public function store ( $ key , $ value ) { $ this -> dbProvider -> store ( $ key , $ value ) ; $ this -> origConfig -> set ( $ key , $ value ) ; } | Save item into database and set to current config |
5,635 | public function retrieveAppliedProducts ( Varien_Event_Observer $ observer ) { $ this -> _productIds = $ this -> _getResource ( ) -> getAffectedProductIds ( $ observer -> getEvent ( ) -> getProductCondition ( ) ) ; } | Collects affected products by price rules |
5,636 | public function postApply ( Varien_Event_Observer $ observer ) { $ productIds = array ( ) ; foreach ( $ this -> _productIds as $ productId ) { $ productIds [ ] = EcomDev_Varnish_Model_Processor_Product :: TAG_PREFIX . $ productId ; } $ chunks = array_chunk ( $ productIds , 500 ) ; foreach ( $ chunks as $ tags ) { Mage ... | Clears cache after applying the price rules |
5,637 | protected function getAllowedPaymentFrequencies ( ) { return array ( static :: DAILY , static :: WEEKLY , static :: SEMIMONTHLY , static :: MONTHLY , static :: BIMONTHLY , static :: QUATERLY , static :: EVERY_4_MONTHS , static :: SEMIANNUAL , static :: ANNUAL , ) ; } | Returns an array of valid payment frequencies |
5,638 | public function add ( $ item ) { foreach ( $ this -> _requiredInterfaces as $ interface ) { if ( ! $ item instanceof $ interface ) { throw new RuntimeException ( sprintf ( 'Item "%s" should implement "%s" interface' , get_class ( $ item ) , $ interface ) ) ; } } $ this -> _items [ spl_object_hash ( $ item ) ] = $ item ... | Adds an item to facade |
5,639 | public function remove ( $ item ) { $ hash = spl_object_hash ( $ item ) ; if ( isset ( $ this -> _items [ $ hash ] ) ) { unset ( $ this -> _items [ $ hash ] ) ; } return $ this ; } | Removes items from facade |
5,640 | protected function _initItems ( ) { if ( ! $ this -> _itemsXmlPath ) { throw new RuntimeException ( 'XML Path for facade items is not specified' ) ; } $ config = Mage :: getConfig ( ) -> getNode ( $ this -> _itemsXmlPath ) -> children ( ) ; foreach ( $ config as $ class ) { $ this -> add ( Mage :: getModel ( $ class ) ... | Initializes default facade items |
5,641 | public function items ( $ object = null ) { if ( ! $ this -> _items ) { $ this -> _initItems ( ) ; } $ items = array ( ) ; foreach ( $ this -> _items as $ item ) { if ( $ object !== null && ! $ item -> isApplicable ( $ object ) ) { continue ; } $ items [ ] = $ item ; } return $ items ; } | Retrieves facade items If object is specified it will filter out items by isApplicable interface |
5,642 | public function walk ( $ method , $ arg = null , $ object = null ) { $ result = array ( ) ; foreach ( $ this -> items ( $ object ) as $ item ) { $ itemResult = $ item -> $ method ( $ arg ) ; if ( $ itemResult === $ item ) { continue ; } if ( ! is_array ( $ itemResult ) ) { $ result [ ] = $ itemResult ; } elseif ( isset... | Invokes method on each facade item with specified arguments |
5,643 | private static function initialize ( ) { if ( self :: $ initialized ) return ; self :: $ client = \ OpenId :: getClient ( ) ; self :: $ version = config ( 'openid.api-version' ) ; self :: $ initialized = TRUE ; } | Static class constructor |
5,644 | public function isCancelled ( ) { if ( ! $ this -> testMdSignatures ( ) ) { return false ; } return in_array ( $ this -> getStatus ( ) , [ self :: STATUS_CHARGEBACK , self :: STATUS_FAILED , self :: STATUS_CANCELLED ] ) ; } | Was the payment cancelled? |
5,645 | protected function validateSignatures ( ) { if ( ! $ this -> testMdSignatures ( ) ) { return false ; } if ( $ this -> getSha2Signature ( ) !== null ) { return $ this -> getSha2Signature ( ) === $ this -> calculateSha2Signature ( ) ; } return true ; } | Validates the MD5 signature and if enabled the SHA2 signature . |
5,646 | public function getSkrillAmount ( $ stringFormat = false ) { $ amount = ( double ) $ this -> data [ 'mb_amount' ] ; if ( $ stringFormat ) { $ amount = number_format ( $ amount , 2 , '.' , '' ) ; } return $ amount ; } | Get the total amount of the payment in merchant s currency . |
5,647 | public function getMerchantFields ( array $ keys ) { $ fields = [ ] ; foreach ( $ keys as $ key ) { $ fields [ $ key ] = $ this -> data [ $ key ] ; } return $ fields ; } | Get the fields that the merchant chose to submit in the merchant_fields parameter . |
5,648 | public function calculateMd5Signature ( ) { return strtoupper ( md5 ( $ this -> getMerchantId ( ) . $ this -> getTransactionReference ( ) . $ this -> getSecretWordForMd5Signature ( ) . $ this -> getSkrillAmount ( true ) . $ this -> getSkrillCurrency ( ) . $ this -> getStatus ( ) ) ) ; } | Calculate the 128 bit message digest expressed as a string of thirty - two hexadecimal digits in UPPERCASE . |
5,649 | public function calculateSha2Signature ( ) { return hash ( 'sha256' , $ this -> getMerchantId ( ) . $ this -> getTransactionReference ( ) . $ this -> getSecretWordForMd5Signature ( ) . $ this -> getSkrillAmount ( ) . $ this -> getSkrillCurrency ( ) . $ this -> getStatus ( ) ) ; } | Calculate the 256 bit message digest expressed as a string of sixty - four hexadecimal digits in lowercase . |
5,650 | protected function _beforeToHtml ( ) { Mage :: helper ( 'ecomdev_varnish' ) -> setIsEsiUsed ( true ) ; $ handles = implode ( ',' , $ this -> _handles ) ; $ params = array ( 'handles' => $ handles , 'package' => Mage :: getSingleton ( 'core/design_package' ) -> getPackageName ( ) , 'theme' => Mage :: getSingleton ( 'cor... | Outputs ESI tag |
5,651 | public function getBlockJson ( ) { $ result = array ( 'htmlId' => $ this -> getHtmlId ( ) , 'url' => $ this -> getBlockUrl ( ) ) ; return $ this -> helper ( 'core' ) -> jsonEncode ( $ result ) ; } | Returns block json |
5,652 | public function getMessageTypes ( ) { if ( $ this -> messageTypes === null ) { $ this -> messageTypes = array ( ) ; $ messageTypes = Mage :: getConfig ( ) -> getNode ( self :: XML_PATH_MESSAGE_TYPES ) ; if ( $ messageTypes ) { foreach ( $ messageTypes -> children ( ) as $ typeCode => $ classAlias ) { $ this -> messageT... | Returns message types for varnish cache |
5,653 | public function getMessageTypeByStorage ( $ storageType ) { if ( $ this -> messageTypeByStorageType === null ) { $ types = $ this -> getMessageTypes ( ) ; if ( $ types ) { $ this -> messageTypeByStorageType = array_combine ( array_values ( $ types ) , array_keys ( $ types ) ) ; } else { $ this -> messageTypeByStorageTy... | Returns message type by storage |
5,654 | public function getStorageByMessageType ( $ messageType ) { if ( $ this -> messageTypes === null ) { $ this -> getMessageTypes ( ) ; } if ( ! isset ( $ this -> messageTypes [ $ messageType ] ) ) { return false ; } return Mage :: getSingleton ( $ this -> messageTypes [ $ messageType ] ) ; } | Returns storage by message type |
5,655 | public function addMessages ( $ messages , $ storageType ) { if ( $ messages instanceof Mage_Core_Model_Message_Collection ) { $ messages = $ messages -> getItems ( ) ; } $ this -> scheduledMessages [ $ storageType ] = $ messages ; return $ this ; } | Adds messages for a later use |
5,656 | public function getMessages ( $ types ) { $ result = array ( ) ; foreach ( $ types as $ type ) { $ storage = $ this -> getStorageByMessageType ( $ type ) ; if ( $ storage ) { $ result [ ] = $ storage -> getMessages ( true ) ; } } return $ result ; } | Returns all messages from types passed in argument |
5,657 | public function apply ( ) { if ( ! isset ( $ _SESSION ) || empty ( $ _SESSION ) ) { return $ this ; } foreach ( $ this -> messageBlocks as $ messageBlock ) { foreach ( $ messageBlock -> getMessagesByStorage ( ) as $ storageType => $ messages ) { $ this -> addMessagesByStorageType ( $ storageType , $ messages ) ; } } fo... | Applies changes values stored in message block into session instances |
5,658 | public function setSortColumn ( $ column ) { $ this -> sortColumn = null ; $ found = false ; foreach ( $ this -> getColumns ( ) as $ id => $ params ) { if ( $ id == $ column ) { $ found = ( $ params [ 'sortable' ] === true ) ; break ; } } if ( $ found ) $ this -> sortColumn = $ column ; return $ this ; } | Sort column setter |
5,659 | public function setSortDir ( $ dir ) { if ( in_array ( $ dir , [ self :: DIR_ASC , self :: DIR_DESC ] ) ) $ this -> sortDir = $ dir ; else $ this -> sortDir = self :: DIR_ASC ; return $ this ; } | Sort direction setter |
5,660 | public function setPageNumber ( $ number ) { $ this -> pageNumber = ( $ number === null ? 1 : ( int ) $ number ) ; if ( $ this -> pageNumber < 1 ) $ this -> pageNumber = 1 ; return $ this ; } | Page number setter |
5,661 | public function setPageSize ( $ size ) { $ this -> pageSize = ( $ size === null ? self :: PAGE_SIZE : ( int ) $ size ) ; if ( $ this -> pageSize < 0 ) $ this -> pageSize = self :: PAGE_SIZE ; return $ this ; } | Page size setter |
5,662 | public function setPageParams ( $ params ) { $ this -> setFilters ( json_decode ( @ $ params [ 'filters' ] , true ) ) ; $ this -> setSortColumn ( json_decode ( @ $ params [ 'sort_column' ] , true ) ) ; $ this -> setSortDir ( json_decode ( @ $ params [ 'sort_dir' ] , true ) ) ; $ this -> setPageNumber ( json_decode ( @ ... | Sets sort filter and pagination options |
5,663 | public function describe ( ) { $ columns = [ ] ; foreach ( $ this -> columns as $ id => $ params ) { $ columns [ $ id ] = [ 'title' => $ params [ 'title' ] , 'type' => $ params [ 'type' ] , 'filters' => $ params [ 'filters' ] , 'sortable' => $ params [ 'sortable' ] , 'visible' => $ params [ 'visible' ] , ] ; } return [... | Return table description |
5,664 | public function fetch ( ) { $ adapter = $ this -> getAdapter ( ) ; if ( ! $ adapter ) throw new \ Exception ( "Adapter property is not set" ) ; $ adapter -> check ( $ this ) ; $ adapter -> filter ( $ this ) ; $ adapter -> sort ( $ this ) ; $ result = $ adapter -> paginate ( $ this ) ; $ filters = $ this -> getFilters (... | Fetch data and feed it to front - end |
5,665 | public static function getAvailableTypes ( ) { return [ self :: TYPE_STRING , self :: TYPE_INTEGER , self :: TYPE_FLOAT , self :: TYPE_BOOLEAN , self :: TYPE_DATETIME , ] ; } | List column types |
5,666 | public function getAjaxReloadUrl ( ) { if ( $ this -> _ajaxReloadUrl === null ) { $ this -> _ajaxReloadUrl = $ this -> _getUrl ( 'varnish/ajax/reload' , array ( '_secure' => Mage :: app ( ) -> getStore ( ) -> isCurrentlySecure ( ) ) ) ; } return $ this -> _ajaxReloadUrl ; } | Returns a url for reloading |
5,667 | protected function _initDefaultVarnishHeaders ( $ withoutTags ) { if ( ! $ withoutTags && $ this -> _ttlList ) { $ this -> setVarnishHeader ( self :: HEADER_TTL , min ( $ this -> _ttlList ) . 's' ) ; } if ( ! $ withoutTags && $ this -> _objectTags && ! $ this -> hasVarnishHeader ( self :: HEADER_OBJECTS ) ) { $ objects... | Init default varnish headers |
5,668 | public function getCurrentPageInfo ( ) { $ result = array ( 'handle' => $ this -> getCurrentPage ( ) ) ; if ( Mage :: registry ( 'current_category' ) instanceof Mage_Catalog_Model_Category ) { $ result [ 'category' ] = Mage :: registry ( 'current_category' ) -> getId ( ) ; } if ( Mage :: registry ( 'current_product' ) ... | Returns current page info |
5,669 | public function addVarnishHeader ( $ name , $ value ) { $ header = $ value ; if ( $ this -> hasVarnishHeader ( $ name ) ) { $ header = $ this -> getVarnishHeader ( $ name ) ; if ( ! is_array ( $ header ) ) { $ header = array ( $ header ) ; } $ header [ ] = $ value ; } $ this -> setVarnishHeader ( $ name , $ header ) ; ... | Adds varnish header |
5,670 | protected function _initAllowedPages ( ) { if ( $ this -> _allowedPages === null ) { $ this -> _allowedPages = array ( ) ; foreach ( Mage :: getConfig ( ) -> getNode ( self :: XML_PATH_ALLOWED_PAGES ) -> children ( ) as $ page => $ info ) { $ module = ( $ info -> getAttribute ( 'module' ) ? $ info -> getAttribute ( 'mo... | Init allowed pages from configuration |
5,671 | public function isAllowedCurrentPage ( ) { if ( ! $ this -> isActive ( ) ) { return false ; } $ this -> _initAllowedPages ( ) ; if ( ! $ this -> getCurrentPage ( ) ) { return false ; } return isset ( $ this -> _allowedPages [ $ this -> getCurrentPage ( ) ] ) ; } | Checks if current page is not allowed for varnish cache |
5,672 | public function getCurrentPageTtl ( ) { if ( $ this -> getCurrentPage ( ) ) { $ cacheTtl = ( int ) Mage :: getStoreConfig ( sprintf ( self :: XML_PATH_PAGE_TTL , $ this -> getCurrentPage ( ) ) ) ; if ( $ cacheTtl ) { return $ cacheTtl * 60 ; } } return false ; } | Returns current page TTL in seconds |
5,673 | public function getCustomerSegment ( ) { $ segment = new Varien_Object ( ) ; $ segmentValues = $ this -> _getSegmentValues ( ) ; foreach ( $ segmentValues as $ field => $ configCallbackPair ) { if ( is_array ( $ configCallbackPair ) && Mage :: getStoreConfigFlag ( $ configCallbackPair [ 0 ] ) ) { $ segment -> setData (... | Returns customer segment data used as cache segment |
5,674 | protected function _getSegmentValues ( ) { return array ( 'customer_group_id' => array ( self :: XML_PATH_SEGMENT_CUSTOMER_GROUP , function ( ) { return $ this -> _noSessionCall ? 0 : Mage :: getSingleton ( 'customer/session' ) -> getCustomerGroupId ( ) ; } ) , 'store_id' => array ( self :: XML_PATH_SEGMENT_STORE , fun... | Returns list of segment values callbacks |
5,675 | public function hashData ( $ hashData , $ addDeviceType = true ) { if ( is_array ( $ hashData ) ) { $ hashData = json_encode ( $ hashData ) ; } if ( $ addDeviceType ) { $ hashData .= $ this -> _getRequest ( ) -> getServer ( 'HTTP_X_UA_DEVICE' ) ; } return md5 ( $ hashData ) ; } | Hashes data for varnish |
5,676 | public function cachedHelperCall ( $ helper , $ method , $ cachedValue , $ args = array ( ) ) { if ( $ this -> isActive ( ) && ! $ this -> getIsInternal ( ) ) { return $ cachedValue ; } $ helper = Mage :: helper ( $ helper ) ; if ( ! empty ( $ args ) ) { return call_user_func_array ( array ( $ helper , $ method ) , $ a... | Calls a helper depending on internal level of cache of the page |
5,677 | public function getChecksum ( $ data ) { $ data [ 'salt' ] = $ this -> getEsiKey ( ) ; ksort ( $ data ) ; return md5 ( json_encode ( $ data ) ) ; } | Returns checksum for supplied data array |
5,678 | public function validateChecksum ( $ data ) { if ( ! isset ( $ data [ 'checksum' ] ) || ! $ this -> getEsiKey ( ) ) { return false ; } $ suppliedChecksum = $ data [ 'checksum' ] ; unset ( $ data [ 'checksum' ] ) ; return $ suppliedChecksum === $ this -> getChecksum ( $ data ) ; } | Validates checksum of esi request |
5,679 | public function generateToken ( ) { $ token = Mage :: helper ( 'core' ) -> getRandomString ( 16 ) ; $ this -> addCookie ( self :: COOKIE_TOKEN , $ token ) ; $ this -> addCookie ( self :: COOKIE_TOKEN_CHECKSUM , $ this -> getChecksum ( array ( 'token' => $ token ) ) ) ; return $ this ; } | Generates CSRF token for a user |
5,680 | public function validateToken ( $ token ) { $ tokenChecksum = Mage :: getSingleton ( 'ecomdev_varnish/cookie' ) -> get ( self :: COOKIE_TOKEN_CHECKSUM ) ; if ( $ tokenChecksum === $ this -> getChecksum ( array ( 'token' => $ token ) ) ) { return true ; } return false ; } | Validates a token value |
5,681 | public function set ( $ cookie , $ value , $ httpOnly = false ) { $ this -> _cookies [ $ cookie ] = array ( 'value' => $ value , 'http_only' => $ httpOnly ) ; return $ this ; } | Stores a cookie for scheduled set cookie calls |
5,682 | public function get ( $ cookie ) { if ( ! $ this -> has ( $ cookie ) ) { if ( $ this -> getRequest ( ) ) { return $ this -> getRequest ( ) -> getCookie ( $ cookie ) ; } return null ; } return $ this -> _cookies [ $ cookie ] [ 'value' ] ; } | Retrieves a cookie value from scheduled list or request cookie |
5,683 | public function apply ( ) { Mage :: dispatchEvent ( 'ecomdev_varnish_cookie_apply_before' , array ( 'cookie' => $ this ) ) ; foreach ( $ this -> getAll ( ) as $ cookieName => $ data ) { Mage :: getSingleton ( 'core/cookie' ) -> set ( $ cookieName , $ data [ 'value' ] , null , null , null , null , $ data [ 'http_only' ]... | Applies cookies to be set |
5,684 | protected function checkFilter ( $ filter , $ type , $ test , $ real ) { if ( $ type == Table :: TYPE_DATETIME ) { if ( $ filter == Table :: FILTER_BETWEEN && is_array ( $ test ) && count ( $ test ) == 2 ) { $ test = [ $ test [ 0 ] ? new \ DateTime ( '@' . $ test [ 0 ] ) : null , $ test [ 1 ] ? new \ DateTime ( '@' . $... | Check and apply filter |
5,685 | public function sameValueAs ( ValueObjectInterface $ enum ) { if ( false === Util :: classEquals ( $ this , $ enum ) ) { return false ; } return $ this -> toNative ( ) === $ enum -> toNative ( ) ; } | Tells whether two Enum objects are sameValueAs by comparing their values . |
5,686 | public function addHandler ( string $ type , RequestHandlerInterface $ handler ) : void { $ this -> handlers [ $ type ] = $ handler ; } | Adds a request handler |
5,687 | protected function getConfigArrayOption ( $ optionName , $ defaultValue = null ) { if ( ! isset ( $ this -> config [ $ optionName ] ) ) { return $ defaultValue ; } return $ this -> config [ $ optionName ] ; } | Returns configuration array option |
5,688 | protected function initBackend ( ) { $ this -> backendList = array ( ) ; $ this -> balancedBackendList = array ( ) ; foreach ( $ this -> getConfigArrayOption ( 'backend' , array ( ) ) as $ backendName => $ option ) { if ( ! isset ( $ option [ 'ip' ] ) || ! isset ( $ option [ 'port' ] ) ) { continue ; } $ this -> backen... | Initializes backend options |
5,689 | public function getBackendOption ( $ backendName , $ option , $ defaultOption = null ) { $ backendConfig = $ this -> getConfigArrayOption ( 'backend' , array ( ) ) ; if ( isset ( $ backendConfig [ $ backendName ] [ $ option ] ) ) { return $ backendConfig [ $ backendName ] [ $ option ] ; } $ optionConfig = $ this -> get... | Returns backend option from configuration |
5,690 | public function getCookieName ( $ type ) { $ defaultCookieNames = $ this -> getConfigArrayOption ( 'default_cookie_names' , [ 'segment' => EcomDev_Varnish_Model_Customer_Observer :: COOKIE_SEGMENT ] ) ; $ cookieNames = $ this -> getConfigArrayOption ( 'cookie_names' , [ ] ) ; $ cookieNames = $ defaultCookieNames + $ co... | Returns cookie name for VCL configuration |
5,691 | public function load ( $ collection = null ) { $ items = array ( ) ; $ list = DB :: table ( $ this -> table ) ; if ( $ collection !== null ) { $ list = $ list -> where ( 'key' , 'LIKE' , $ collection . '%' ) ; } $ list = $ list -> pluck ( 'value' , 'key' ) ; foreach ( $ list as $ key => $ value ) { $ value = json_decod... | Load the given configuration collection . |
5,692 | public function store ( $ key , $ value ) { if ( ! is_array ( $ value ) ) { $ value = array ( $ key => $ value ) ; } else { $ value = array_dot ( $ value ) ; foreach ( $ value as $ k => $ v ) { $ value [ $ key . '.' . $ k ] = $ v ; unset ( $ value [ $ k ] ) ; } } foreach ( $ value as $ k => $ v ) { $ this -> _store ( $... | Save item to the database or update the existing one |
5,693 | public function clear ( ) { try { DB :: table ( $ this -> table ) -> truncate ( ) ; } catch ( \ Exception $ e ) { throw new SaveException ( "Cannot clear database: " . $ e -> getMessage ( ) ) ; } } | Clear the table with settings |
5,694 | public function listDb ( $ wildcard = null ) { $ query = DB :: table ( $ this -> table ) ; if ( ! empty ( $ wildcard ) ) { $ query = $ query -> where ( 'key' , 'LIKE' , $ wildcard . '%' ) ; } return $ query ; } | Return query builder with list of settings from database |
5,695 | public function sameValueAs ( ValueObjectInterface $ uuid ) { if ( false === Util :: classEquals ( $ this , $ uuid ) ) { return false ; } return $ this -> toNative ( ) === $ uuid -> toNative ( ) ; } | Tells whether two UUID are equal by comparing their values . |
5,696 | protected function validate ( $ session , $ request ) { $ locked = $ session -> get ( self :: LOCKED_FIELD ) ; return ! ( $ locked [ 'ip' ] != $ request -> getClientIp ( ) || $ locked [ 'agent' ] != md5 ( $ request -> server ( 'HTTP_USER_AGENT' ) ) ) ; } | Check if IP or Agent changed |
5,697 | public function getAll ( ) { $ endpoint = "{$this->apiUrl}/webhooks/stores" ; $ res = Requests :: get ( $ endpoint , array ( ) , $ this -> options ) ; $ this -> validateResponse ( $ res ) ; return json_decode ( $ res -> body , true ) ; } | Returns a list of all registed webhooks |
5,698 | public function sendData ( $ data ) { $ url = $ this -> getEndpoint ( ) . '?' . http_build_query ( $ data ) ; $ httpResponse = $ this -> httpClient -> get ( $ url ) -> send ( ) ; $ xml = $ httpResponse -> xml ( ) ; return $ this -> createResponse ( $ xml ) ; } | Send the skrill request . |
5,699 | protected function createResponse ( $ xml ) { $ requestClass = get_class ( $ this ) ; $ responseClass = substr ( $ requestClass , 0 , - 7 ) . 'Response' ; return $ this -> response = new $ responseClass ( $ this , $ xml ) ; } | Create a proper response based on the request . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.