idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
5,700 | public static function bytes ( $ bytes , $ precision = 2 ) { $ size = array ( 'bytes' , 'kb' , 'mb' , 'gb' , 'tb' , 'pb' , 'eb' , 'zb' , 'yb' ) ; $ factor = floor ( ( strlen ( $ bytes ) - 1 ) / 3 ) ; return sprintf ( "%.{$precision}f" , $ bytes / pow ( 1024 , $ factor ) ) . ' ' . @ $ size [ $ factor ] ; } | Format byte code to human understand |
5,701 | public static function toLatin ( $ string , $ separator = '' , $ clean = false ) { $ cyrillicCount = count ( self :: $ cyr ) ; for ( $ i = 0 ; $ i < $ cyrillicCount ; $ i ++ ) { $ string = str_replace ( self :: $ cyr [ $ i ] , self :: $ lat [ $ i ] , $ string ) ; } $ string = preg_replace ( "/([qwrtpsdfghklzxcvbnmQWRTP... | Transliterate cyrillic to latin |
5,702 | public function getTags ( $ object ) { $ tags = $ this -> _collectTags ( $ object ) ; if ( is_string ( $ tags ) ) { $ tags = array ( $ tags => $ tags ) ; } elseif ( ! is_array ( $ tags ) ) { return array ( ) ; } return $ tags ; } | Collects list of objects that can be used by object retrievers |
5,703 | protected function assertSameCurrency ( Price $ a , Price $ b ) { if ( $ a -> getCurrency ( ) != $ b -> getCurrency ( ) ) { throw new CurrencyMismatchException ; } } | Ensures that the two Price instances have the same currency . |
5,704 | protected function assertAmountFormat ( $ amount ) { if ( is_float ( $ amount ) ) { throw new InvalidArgumentException ( sprintf ( 'The provided amount "%s" must be a string, not a float.' , $ amount ) ) ; } if ( ! is_numeric ( $ amount ) ) { throw new InvalidArgumentException ( sprintf ( 'The provided amount "%s" must... | Ensures that the provided amount is a numeric string . |
5,705 | protected function newPrice ( $ amount , $ currency = null ) { if ( strpos ( $ amount , '.' ) != FALSE ) { $ amount = rtrim ( $ amount , '0' ) ; $ amount = rtrim ( $ amount , '.' ) ; } $ currency = $ currency ? : $ this -> currency ; return new static ( $ amount , $ currency ) ; } | Creates a new Price instance using the provided amount . |
5,706 | public function same ( $ value = 0 , $ prec = null ) { if ( $ value instanceof $ this && $ value -> prec == $ this -> prec && ( $ prec === null || $ value -> prec == $ prec ) ) { return $ value ; } $ class = get_class ( $ this ) ; return new $ class ( $ value , $ prec ) ; } | Make the same type object |
5,707 | public function add ( $ op ) { $ dst = clone $ this ; $ dst -> value = $ this -> _fix ( $ this -> _add ( $ this -> same ( $ op , $ this -> prec ) ) ) ; return $ dst ; } | Add two numbers |
5,708 | public function sub ( $ op ) { $ dst = clone $ this ; $ dst -> value = $ this -> _fix ( $ this -> _sub ( $ this -> same ( $ op , $ this -> prec ) ) ) ; return $ dst ; } | Substract two numbers |
5,709 | public function mul ( $ op ) { $ dst = clone $ this ; $ dst -> value = $ this -> _fix ( $ this -> _mul ( $ this -> same ( $ op , $ this -> prec ) ) ) ; return $ dst ; } | Multiply two numbers |
5,710 | public function div ( $ op ) { $ dst = clone $ this ; $ op = $ this -> same ( $ op , $ this -> prec ) ; if ( $ op -> eq ( 0 ) ) throw new ArithmeticException ( sprintf ( 'Division by zero (%s)' , json_encode ( $ op ) ) ) ; $ dst -> value = $ this -> _fix ( $ this -> _div ( $ op ) ) ; return $ dst ; } | Divide number by operand |
5,711 | public function mod ( $ op ) { $ dst = clone $ this ; $ op = $ this -> same ( $ op , $ this -> prec ) -> truncate ( ) ; if ( $ op -> eq ( 0 ) ) throw new ArithmeticException ( sprintf ( 'Division by zero (%s)' , json_encode ( $ op ) ) ) ; $ dst -> value = $ this -> _fix ( $ this -> _mod ( $ op ) ) ; return $ dst ; } | Module of division |
5,712 | public function pow ( $ op ) { $ dst = clone $ this ; $ op = $ this -> same ( $ op , $ this -> prec ) -> truncate ( ) ; $ dst -> value = $ this -> _fix ( $ this -> _pow ( $ op ) ) ; return $ dst ; } | Power of number |
5,713 | public function sqrt ( ) { $ dst = clone $ this ; $ dst -> value = $ this -> _fix ( $ this -> _sqrt ( ) ) ; return $ dst ; } | Square root of number |
5,714 | public function round ( $ prec = 0 ) { $ dst = clone $ this ; $ dst -> value = $ this -> _round ( $ this -> value , $ prec ) ; return $ dst ; } | Round number with specific precision |
5,715 | public function ceil ( $ prec = 0 ) { $ dst = clone $ this ; $ dst -> value = $ this -> _ceil ( $ this -> value , $ prec ) ; return $ dst ; } | Ceil number with specific precision |
5,716 | public function floor ( $ prec = 0 ) { $ dst = clone $ this ; $ dst -> value = $ this -> _floor ( $ this -> value , $ prec ) ; return $ dst ; } | Floor number with specific precision |
5,717 | public function min ( $ op ) { $ op = $ this -> same ( $ op , $ this -> prec ) ; return $ this -> lt ( $ op ) ? clone $ this : $ op ; } | Find the minimum of two numbers |
5,718 | public function max ( $ op ) { $ op = $ this -> same ( $ op , $ this -> prec ) ; return $ this -> gt ( $ op ) ? clone $ this : $ op ; } | Find the maximum of two numbers |
5,719 | public function epsilon ( ) { $ half = $ this -> same ( '0.5' , $ this -> prec + 1 ) ; $ factor = $ this -> same ( '10' , 0 ) -> pow ( $ this -> prec ) ; return $ half -> div ( $ factor ) ; } | Calcualate epsilon for float comparision |
5,720 | public function setReturnUrlTarget ( $ value ) { switch ( $ value ) { case '_top' : $ value = 1 ; break ; case '_parent' : $ value = 2 ; break ; case '_self' : $ value = 3 ; break ; case '_blank' : $ value = 4 ; break ; default : $ value = ( int ) $ value ; } return $ this -> setParameter ( 'returnUrlTarget' , $ value ... | Set the target in which the return url value is displayed upon successful payment from the customer . |
5,721 | public function setCancelUrlTarget ( $ value ) { switch ( $ value ) { case '_top' : $ value = 1 ; break ; case '_parent' : $ value = 2 ; break ; case '_self' : $ value = 3 ; break ; case '_blank' : $ value = 4 ; break ; default : $ value = ( int ) $ value ; } return $ this -> setParameter ( 'cancelUrlTarget' , $ value ... | Set the target in which the cancel url value is displayed upon cancellation of payment by the customer . |
5,722 | public function navigateStreamFeed ( StreamFeed $ streamFeed , LinkRelation $ relation ) : ? StreamFeed { $ url = $ streamFeed -> getLinkUrl ( $ relation ) ; if ( empty ( $ url ) ) { return null ; } return $ this -> readStreamFeed ( $ url , $ streamFeed -> getEntryEmbedMode ( ) ) ; } | Navigates a stream feed through link relations . |
5,723 | public function openStreamFeed ( $ streamName , EntryEmbedMode $ embedMode = null ) : StreamFeed { $ url = $ this -> getStreamUrl ( $ streamName ) ; return $ this -> readStreamFeed ( $ url , $ embedMode ) ; } | Opens a stream feed for read and navigation . |
5,724 | public function readEvent ( $ eventUrl ) : Event { $ request = $ this -> getJsonRequest ( $ eventUrl ) ; $ this -> sendRequest ( $ request ) ; $ this -> ensureStatusCodeIsGood ( $ eventUrl ) ; $ jsonResponse = $ this -> lastResponseAsJson ( ) ; return $ this -> createEventFromResponseContent ( $ jsonResponse [ 'content... | Read a single event . |
5,725 | public function readEventBatch ( array $ eventUrls ) : array { $ requests = array_map ( function ( $ eventUrl ) { return $ this -> getJsonRequest ( $ eventUrl ) ; } , $ eventUrls ) ; $ responses = $ this -> httpClient -> sendRequestBatch ( $ requests ) ; return array_map ( function ( $ response ) { $ data = json_decode... | Reads a batch of events . |
5,726 | private function extractStreamVersionFromLastResponse ( string $ streamUrl ) { $ locationHeaders = $ this -> getLastResponse ( ) -> getHeader ( 'Location' ) ; if ( ! empty ( $ locationHeaders [ 0 ] ) && 0 === strpos ( $ locationHeaders [ 0 ] , $ streamUrl ) ) { $ version = substr ( $ locationHeaders [ 0 ] , strlen ( $ ... | Extracts created version after writing to a stream . |
5,727 | public function controllerActionPredispatch ( Varien_Event_Observer $ observer ) { if ( ! $ this -> _getHelper ( ) -> isActive ( ) ) { return $ this ; } $ controllerAction = $ observer -> getControllerAction ( ) ; $ this -> _getHelper ( ) -> setCurrentPage ( strtolower ( $ controllerAction -> getFullActionName ( '_' ) ... | Sets the current page on pre dispatch |
5,728 | public function controllerActionLayoutLoadBefore ( Varien_Event_Observer $ observer ) { if ( ! $ this -> _getHelper ( ) -> isActive ( ) ) { return ; } $ updateModel = $ observer -> getLayout ( ) -> getUpdate ( ) ; $ handles = $ updateModel -> getHandles ( ) ; $ allowedEsi = $ this -> _getHelper ( ) -> getIsEsiAllowed (... | Adds ESI to the layout cache |
5,729 | protected function _addResponseHeaders ( $ controllerAction ) { if ( $ this -> _getHelper ( ) -> isDebug ( ) ) { $ controllerAction -> getResponse ( ) -> setHeader ( 'X-Debug' , '1' ) ; } if ( $ this -> _getHelper ( ) -> getIsEsiUsed ( ) ) { $ controllerAction -> getResponse ( ) -> setHeader ( 'Surrogate-Control' , 'ke... | Adds varnish response headers |
5,730 | public function controllerActionPostdispatch ( Varien_Event_Observer $ observer ) { if ( ! $ this -> _getHelper ( ) -> isActive ( ) ) { return ; } $ controllerAction = $ observer -> getControllerAction ( ) ; if ( ! Mage :: app ( ) -> getStore ( ) -> isAdmin ( ) && $ controllerAction -> getResponse ( ) -> canSendHeaders... | Observes all controller post dispatches |
5,731 | public function performBan ( ) { if ( ! $ this -> _getHelper ( ) -> isActive ( ) ) { return $ this ; } $ tagsToBan = array_unique ( $ this -> _getProcessor ( ) -> getTagsToBan ( ) ) ; if ( $ tagsToBan ) { try { $ tagsToBan = array_map ( array ( Mage :: helper ( 'ecomdev_varnish' ) , 'formatObjectTag' ) , $ tagsToBan ) ... | Performs Varnish BAN of object tags if they exists |
5,732 | public function backgroundBan ( ) { $ queue = Mage :: app ( ) -> getCache ( ) -> load ( self :: VARNISH_CACHE_QUEUE , true ) ; if ( $ queue ) { $ queue = unserialize ( $ queue ) ; $ chunks = array_chunk ( $ queue , 500 ) ; foreach ( $ chunks as $ tags ) { Mage :: getSingleton ( 'ecomdev_varnish/connector' ) -> banTags ... | Background clean up of the cache tags |
5,733 | public function coreBlockAbstractToHtmlAfter ( Varien_Event_Observer $ observer ) { if ( ! $ this -> _getHelper ( ) -> isAllowedCurrentPage ( ) ) { return $ this ; } $ block = $ observer -> getBlock ( ) ; $ objects = $ this -> _getCollector ( ) -> collect ( $ block ) ; array_splice ( $ this -> _collectedObjects , count... | Checks what have been rendered via collectors for passing data later on to processors |
5,734 | public function updateMessageBlock ( Varien_Event_Observer $ observer ) { $ block = $ observer -> getBlock ( ) ; if ( $ block instanceof Mage_Core_Block_Messages && ! ( $ block instanceof EcomDev_Varnish_Block_MessagesInterface ) ) { if ( ! $ this -> _getHelper ( ) -> isAllowedCurrentPage ( ) ) { return $ this ; } Mage... | Updates message block |
5,735 | public function setCardCookie ( $ observer ) { $ quoteData = $ observer -> getQuote ( ) -> debug ( ) ; unset ( $ quoteData [ 'updated_at' ] ) ; $ this -> setCookies ( array ( self :: COOKIE_CART => $ this -> _hashData ( $ quoteData ) , self :: COOKIE_SEGMENT => $ this -> _hashData ( $ this -> _getHelper ( ) -> getCusto... | Sets card cookie |
5,736 | public function setLoginCookie ( ) { $ this -> setCookies ( array ( self :: COOKIE_CART => $ this -> _hashData ( Varien_Date :: now ( ) ) , self :: COOKIE_SEGMENT => $ this -> _hashData ( $ this -> _getHelper ( ) -> getCustomerSegment ( ) ) , self :: COOKIE_CUSTOMER => $ this -> _hashData ( Varien_Date :: now ( ) ) , s... | Sets login cookie |
5,737 | public function setBlockName ( $ blockName ) { $ this -> setData ( 'block_name' , $ blockName ) ; $ this -> append ( $ this -> getLayout ( ) -> getBlock ( $ blockName ) ) ; return $ this ; } | Sets block name |
5,738 | public function setAdditionalCookie ( $ cookie , $ expectedValue = false ) { $ additionalCookie = $ this -> _getData ( '_additional_cookie' ) ; if ( ! $ additionalCookie || ! is_array ( $ additionalCookie ) ) { $ additionalCookie = array ( ) ; } $ additionalCookie [ $ cookie ] = $ expectedValue ; $ this -> setData ( '_... | Sets additional cookie for block |
5,739 | public function removeAdditionalCookie ( $ cookie ) { $ additionalCookie = $ this -> _getData ( '_additional_cookie' ) ; if ( ! $ additionalCookie || ! is_array ( $ additionalCookie ) ) { return $ this ; } if ( isset ( $ additionalCookie [ $ cookie ] ) ) { unset ( $ additionalCookie [ $ cookie ] ) ; } $ this -> setData... | Removes additional cookie from block |
5,740 | public function setTokenInputName ( $ tokenInputName = null ) { if ( $ tokenInputName === null ) { $ tokenInputName = 'form_key' ; } $ this -> setData ( 'token_input_name' , $ tokenInputName ) ; return $ this ; } | Sets token input name |
5,741 | public function removeObservedCssRule ( $ rule ) { if ( isset ( $ this -> observedCssRules [ $ rule ] ) ) { unset ( $ this -> observedCssRules [ $ rule ] ) ; } return $ this ; } | Removes observed css rule |
5,742 | public function setUrlKeyParam ( $ urlKeyParam = null ) { if ( $ urlKeyParam === null ) { $ urlKeyParam = $ this -> getTokenInputName ( ) ; } $ this -> setData ( 'url_key_param' , $ urlKeyParam ) ; return $ this ; } | Sets url key param name |
5,743 | public function setCookieName ( $ cookieName = null ) { if ( $ cookieName === null ) { $ cookieName = EcomDev_Varnish_Helper_Data :: COOKIE_TOKEN ; } $ this -> setData ( 'cookie_name' , $ cookieName ) ; return $ this ; } | Sets cookie name for token retrieval |
5,744 | public function getJson ( ) { $ json = array ( 'urlKeyParam' => $ this -> getUrlKeyParam ( ) , 'inputFieldName' => $ this -> getTokenInputName ( ) , 'observedCssRules' => $ this -> getObservedCssRules ( ) , 'requestUrl' => $ this -> getTokenUrl ( ) , 'cookieName' => $ this -> getCookieName ( ) ) ; return json_encode ( ... | Returns json for JavaScript class |
5,745 | public function isApplicable ( $ object ) { foreach ( $ this -> _applicableClasses as $ className ) { if ( $ object instanceof $ className ) { return true ; } } return false ; } | Returns true if one of the object is an instance of applicable class |
5,746 | public function setMaxDate ( $ maxDate ) { $ date = \ DateTime :: createFromFormat ( self :: MAX_DATE_FORMAT , $ maxDate ) ; $ isValid = $ date && $ date -> format ( self :: MAX_DATE_FORMAT ) == $ maxDate ; if ( ! $ isValid ) { throw new \ InvalidArgumentException ( 'Maximum payment date must be in that format: ' . sel... | This method will define a due date for the payment |
5,747 | public function sameValueAs ( ValueObjectInterface $ stringLiteral ) { if ( false === Util :: classEquals ( $ this , $ stringLiteral ) ) { return false ; } return $ this -> toNative ( ) === $ stringLiteral -> toNative ( ) ; } | Tells whether two string literals are equal by comparing their values . |
5,748 | public function getDefaultProviders ( ) { $ endpoint = "{$this->apiUrl}/providers/true" ; $ res = Requests :: get ( $ endpoint ) ; $ this -> validateResponse ( $ res ) ; return json_decode ( $ res -> body , true ) ; } | Return a list of the default Cash Providers of ComproPago |
5,749 | public function getProviders ( $ limit = 0 , $ currency = 'MXN' ) { $ endpoint = "{$this->apiUrl}/providers" ; if ( $ limit > 0 ) { $ endpoint .= '?order_total=' . $ limit ; } if ( $ limit > 0 && ! empty ( $ currency ) && $ currency != 'MXN' ) { $ endpoint .= '¤cy=' . $ currency ; } $ res = Requests :: get ( $ en... | Return a specific providers filtered by CP keys and order amounr |
5,750 | public function createOrder ( $ data ) { $ endpoint = "{$this->apiUrl}/charges" ; $ res = Requests :: post ( $ endpoint , $ this -> headers , json_encode ( $ data ) , $ this -> options ) ; $ this -> validateResponse ( $ res ) ; return json_decode ( $ res -> body , true ) ; } | Create a cash order in ComproPago |
5,751 | public function verifyOrder ( $ orderId ) { $ endpoint = "{$this->apiUrl}/charges/{$orderId}" ; $ res = Requests :: get ( $ endpoint , array ( ) , $ this -> options ) ; $ this -> validateResponse ( $ res ) ; return json_decode ( $ res -> body , true ) ; } | Verify order status by id |
5,752 | protected static function normalizeArray ( array $ content ) { foreach ( $ content as $ key => $ value ) { if ( $ value instanceof \ SimpleXMLElement ) { if ( $ value -> count ( ) ) { $ content [ $ key ] = static :: normalizeArray ( ( array ) $ value ) ; } else { $ content [ $ key ] = null ; } } elseif ( is_array ( $ v... | Server returns everything in XML within the automb tag so a simple implementation to translate it to an array is enough |
5,753 | public function sendToOrder ( $ orderId , $ phone ) { $ endpoint = "{$this->apiUrl}/charges/{$orderId}/sms" ; $ data = [ "customer_phone" => $ phone ] ; $ res = Requests :: post ( $ endpoint , $ this -> headers , json_encode ( $ data ) , $ this -> options ) ; $ this -> validateResponse ( $ res ) ; return json_decode ( ... | Send SMS instructions for a specific order |
5,754 | public function checkMinsize ( \ Phalcon \ Http \ Request \ File $ file , $ value ) { if ( is_array ( $ value ) === true ) { $ value = $ value [ key ( $ value ) ] ; } if ( $ file -> getSize ( ) < ( int ) $ value ) { $ this -> errors [ ] = sprintf ( Message :: get ( 'INVALID_MIN_SIZE' ) , $ file -> getName ( ) , Format ... | Check minimum file size |
5,755 | public function checkDirectory ( \ Phalcon \ Http \ Request \ File $ file = null , $ value ) { if ( is_array ( $ value ) === true ) { $ value = $ value [ key ( $ value ) ] ; } if ( file_exists ( $ value ) === false ) { $ this -> errors [ ] = sprintf ( Message :: get ( 'INVALID_UPLOAD_DIR' ) , $ value ) ; return false ;... | Check upload directory |
5,756 | public function checkDynamic ( \ Phalcon \ Http \ Request \ File $ file = null , $ directory , $ permission = 0777 ) { if ( is_dir ( $ directory ) === false && file_exists ( $ directory ) === false ) { mkdir ( rtrim ( $ directory , '/' ) . DIRECTORY_SEPARATOR , $ permission , true ) ; } return true ; } | Create Directory if not exist |
5,757 | public function validateResponse ( Requests_Response $ res ) { $ body = json_decode ( $ res -> body , true ) ; if ( $ res -> status_code != 200 || ( isset ( $ body [ 'code' ] ) && $ body [ 'code' ] != 200 ) ) { $ message = sprintf ( 'Request Error [%d]: %s' , $ res -> status_code , $ res -> body ) ; throw new \ Excepti... | Validate if the response of the ComproPago API is a success response or an error response |
5,758 | public function getSessionId ( ) { return isset ( $ this -> data -> sid ) ? ( string ) $ this -> data -> sid : null ; } | Get the session identifier to be submitted at the next step . |
5,759 | protected function _initVarnishPool ( ) { $ this -> pool = new VarnishPool ( ) ; $ addresses = Mage :: getStoreConfig ( self :: XML_PATH_VARNISH_SERVER ) ; $ secret = Mage :: getStoreConfig ( self :: XML_PATH_VARNISH_SECRET ) ; if ( Mage :: getStoreConfigFlag ( self :: XML_PATH_VARNISH_SECRET_NEWLINE ) ) { $ secret .= ... | Initializes varnish pool |
5,760 | public function banTags ( $ tags ) { try { $ this -> getVarnishPool ( ) -> ban ( 'obj.http.' . self :: HEADER_OBJECTS . ' ~ ' . implode ( '|' , $ tags ) ) ; } catch ( VarnishException $ e ) { Mage :: logException ( $ e ) ; } return $ this ; } | Ban list of tags |
5,761 | public function walk ( $ method , $ firstArg = null , $ secondArg = null ) { if ( $ method === 'purge' ) { $ method = 'ban' ; } if ( $ firstArg === null && $ secondArg === null ) { $ this -> getVarnishPool ( ) -> $ method ( ) ; } elseif ( $ secondArg === null ) { $ this -> getVarnishPool ( ) -> $ method ( $ firstArg ) ... | Invokes method on each adapter . |
5,762 | public function toArray ( ) { return array ( 'e' => $ this -> entity , 'r' => $ this -> reference , 'v' => $ this -> value , 'k' => $ this -> authorizationKey , 's' => $ this -> status , 't_key' => $ this -> key , ) ; } | Return array representation |
5,763 | protected function _parseArgs ( ) { foreach ( $ _SERVER [ 'argv' ] as $ index => $ argument ) { if ( isset ( $ this -> _actionArgsMap [ $ argument ] ) ) { $ this -> _action = $ argument ; unset ( $ _SERVER [ 'argv' ] [ $ index ] ) ; break ; } unset ( $ _SERVER [ 'argv' ] [ $ index ] ) ; } parent :: _parseArgs ( ) ; } | Parses actions for shell script |
5,764 | public function run ( ) { if ( $ this -> _action === null ) { die ( $ this -> usageHelp ( ) ) ; } $ reflection = new ReflectionClass ( __CLASS__ ) ; $ methodName = 'run' . uc_words ( $ this -> _action , '' , ':' ) ; if ( $ reflection -> hasMethod ( $ methodName ) ) { try { Mage :: app ( 'admin' ) ; $ this -> $ methodNa... | Runs scripts itself |
5,765 | protected function getConfigBlock ( ) { $ designPackage = Mage :: getSingleton ( 'core/design_package' ) ; $ designPackage -> setArea ( 'shell' ) ; $ block = Mage :: app ( ) -> getLayout ( ) -> createBlock ( 'ecomdev_varnish/vcl_config' ) ; return $ block ; } | Returns block instance |
5,766 | protected function runVclGenerate ( ) { $ config = Mage :: getModel ( 'ecomdev_varnish/vcl_config_json' , array ( 'file' => $ this -> getArg ( 'config' ) ) ) ; $ block = $ this -> getConfigBlock ( ) ; if ( $ version = $ this -> getArg ( 'version' ) ) { $ block -> setVersion ( $ version ) ; } if ( $ template = $ this ->... | Generates VCL configuration |
5,767 | protected function runCacheBan ( ) { $ connector = Mage :: getSingleton ( 'ecomdev_varnish/connector' ) ; $ header = $ this -> getArg ( 'header' ) ; if ( empty ( $ header ) ) { $ header = 'req.url' ; } $ value = $ this -> getArg ( 'value' ) ; $ expression = $ header . ' ~ ' . $ value ; $ connector -> getVarnishPool ( )... | Ban cache item |
5,768 | protected function runCacheBanList ( ) { $ connector = Mage :: getSingleton ( 'ecomdev_varnish/connector' ) ; foreach ( $ connector -> getVarnishPool ( ) -> getServers ( ) as $ server ) { fwrite ( STDOUT , sprintf ( 'Ban list for server %s %s' , ( string ) $ server , PHP_EOL ) ) ; fwrite ( STDOUT , $ server -> execute ... | Bans cache list |
5,769 | public function preDispatch ( ) { $ this -> _getHelper ( ) -> disableSessionForControllerAction ( 'token' , $ this ) ; parent :: preDispatch ( ) ; $ this -> _getHelper ( ) -> setIsEsiAllowed ( false ) ; $ this -> _getHelper ( ) -> setIsInternal ( true ) ; Mage :: app ( ) -> setUseSessionVar ( false ) ; Mage :: app ( ) ... | Disables ESI processing and marks request as internal |
5,770 | public function getGroupedHtml ( ) { $ name = $ this -> getNameInLayout ( ) ; $ htmlId = uniqid ( $ name ) ; $ types = [ ] ; foreach ( $ this -> _usedStorageTypes as $ type ) { $ type = $ this -> getVarnishMessageModel ( ) -> getMessageTypeByStorage ( $ type ) ; if ( ! $ type ) { continue ; } $ types [ ] = $ type ; } r... | Returns JS that is required to load messages |
5,771 | public function addStorageType ( $ type ) { parent :: addStorageType ( $ type ) ; if ( ! is_string ( $ type ) ) { return $ this ; } foreach ( $ this -> getMessageCollection ( ) -> getItems ( ) as $ item ) { $ this -> storageMessages [ $ type ] [ ] = $ item ; } $ this -> getMessageCollection ( ) -> clear ( ) ; return $ ... | Add used storage type |
5,772 | public function setRules ( array $ rules ) { foreach ( $ rules as $ key => $ values ) { if ( ( is_array ( $ values ) === true && empty ( $ values ) === false ) || is_callable ( $ values ) ) { $ this -> rules [ $ key ] = $ values ; } else { $ this -> rules [ $ key ] = trim ( $ values ) ; } } return $ this ; } | Setting up rules for uploaded files |
5,773 | public function truncate ( ) { if ( empty ( $ this -> info ) === false ) { foreach ( $ this -> info as $ n => $ file ) { if ( file_exists ( $ file [ 'path' ] ) ) { unlink ( $ file [ 'path' ] ) ; } } } } | Truncate uploaded files |
5,774 | protected function registerGuard ( ) { \ Auth :: extend ( 'openid' , function ( $ app , $ name , array $ config ) { return new CustomSessionGuard ( $ app [ 'session.store' ] ) ; } ) ; \ Auth :: extend ( 'basic-api' , function ( $ app , $ name , array $ config ) { return new CustomTokenGuard ( ) ; } ) ; } | Register Guard Session |
5,775 | protected function createTables ( ) { if ( empty ( self :: $ tables ) ) { throw new \ Exception ( 'Cannot create tables, as no configuration file given, or the ::$tables is not overridden.' ) ; } $ client = $ this -> dynamoDb -> getClient ( ) ; foreach ( self :: $ tables as $ tableData ) { $ tableName = $ tableData [ '... | Creates the tables defined in configuration file or overridden . |
5,776 | protected static function parseCommand ( ) { global $ argv ; $ start_file = $ argv [ 0 ] ; if ( ! isset ( $ argv [ 1 ] ) ) { exit ( "Usage: php yourfile.php {start|stop|restart|reload|status}\n" ) ; } $ command = trim ( $ argv [ 1 ] ) ; $ command2 = isset ( $ argv [ 2 ] ) ? $ argv [ 2 ] : '' ; $ mode = '' ; if ( $ comm... | Parse command . php yourfile . php start | stop | restart | reload | status |
5,777 | protected static function exitAndClearAll ( ) { foreach ( self :: $ _workers as $ worker ) { $ socket_name = $ worker -> getSocketName ( ) ; if ( $ worker -> transport === 'unix' && $ socket_name ) { list ( , $ address ) = explode ( ':' , $ socket_name , 2 ) ; @ unlink ( $ address ) ; } } @ unlink ( self :: $ pidFile )... | Exit current process . |
5,778 | public function listen ( ) { if ( ! $ this -> _socketName || $ this -> _mainSocket ) { return ; } Autoloader :: setRootPath ( $ this -> _autoloadRootPath ) ; list ( $ scheme , $ address ) = explode ( ':' , $ this -> _socketName , 2 ) ; if ( ! isset ( self :: $ _builtinTransports [ $ scheme ] ) ) { if ( class_exists ( $... | Listen port . |
5,779 | public function integer ( $ column , $ autoIncrement = false , $ unsigned = false ) { return $ this -> addColumn ( 'INTEGER' , $ column , compact ( 'autoIncrement' , 'unsigned' ) ) ; } | Create a new integer column on the table . |
5,780 | public function first ( Model $ parentModel , Model $ relatedModel , $ type , $ direction = 'any' ) { $ relation = $ this -> firstRelation ( $ parentModel , $ relatedModel , $ type , $ direction ) ; if ( is_null ( $ relation ) ) return null ; return $ this -> edgeFromRelationWithDirection ( $ relation , $ parentModel ,... | Get the first edge relationship between two models . |
5,781 | public function findIdentityById ( int $ identityId ) : Entity \ Identity { $ identity = new Entity \ Identity ; $ identity -> setId ( $ identityId ) ; $ this -> repository -> load ( $ identity , Entity \ Identity :: class ) ; if ( $ identity -> getAccountId ( ) === null ) { $ this -> logger -> notice ( 'identity not f... | Locates identity based on ID |
5,782 | public function findStandardIdentityByIdentifier ( string $ identifier ) : Entity \ StandardIdentity { $ identity = new Entity \ StandardIdentity ; $ identity -> setIdentifier ( $ identifier ) ; $ this -> repository -> load ( $ identity ) ; if ( $ identity -> getId ( ) === null ) { $ this -> logger -> notice ( 'identit... | Locates identity based on email address |
5,783 | protected function getReferences ( array $ row ) { $ references = [ ] ; $ types = [ ] ; foreach ( $ row as & $ field ) { $ type = gettype ( $ field ) ; if ( $ type === 'integer' ) { $ types [ ] = 'i' ; } elseif ( $ type === 'double' ) { $ types [ ] = 'd' ; } else { $ types [ ] = 's' ; } $ references [ ] = & $ field ; }... | Copies an array to an array of referenced values |
5,784 | public function getSerialId ( ) { if ( $ this -> id ) return $ this -> id ; $ id = $ this -> generateSerialId ( ) ; $ this -> setId ( $ id ) ; return $ id ; } | Get a new serial id |
5,785 | public static function find ( $ id , array $ columns = [ ] ) { $ model = static :: getInstance ( ) ; $ key = static :: getModelKey ( $ id , $ model ) ; $ query = [ 'ConsistentRead' => true , 'TableName' => $ model -> getTable ( ) , 'Key' => $ key , ] ; if ( ! empty ( $ columns ) ) { $ query [ 'AttributesToGet' ] = $ co... | Find a record . |
5,786 | public static function first ( $ columns = [ ] ) { $ model = static :: getInstance ( ) ; $ item = $ model -> getAll ( $ columns , 1 ) ; return $ item -> first ( ) ; } | Return the first result . |
5,787 | public static function where ( $ column , $ operator = null , $ value = null , $ boolean = 'and' ) { if ( $ boolean !== 'and' ) { throw new NotSupportedException ( 'Only support "and" in where clause' ) ; } $ model = static :: getInstance ( ) ; if ( is_array ( $ column ) ) { foreach ( $ column as $ key => $ value ) { $... | Static where function adds where conditions to the model . |
5,788 | public function sort ( $ direction ) { if ( strtolower ( $ direction ) === self :: DIRECTION_DESC ) { $ this -> scanIndexForward = false ; } else { $ this -> scanIndexForward = true ; } } | Set the sort order for the current search query . |
5,789 | protected function getAll ( array $ columns = [ ] , $ limit = - 1 ) { $ query = [ 'TableName' => $ this -> getTable ( ) , ] ; $ op = 'Scan' ; if ( $ limit > - 1 ) { $ query [ 'limit' ] = $ limit ; } if ( ! empty ( $ columns ) ) { $ query [ 'AttributesToGet' ] = $ columns ; } if ( ! empty ( $ this -> where ) ) { if ( $ ... | Gets all values for given columns . |
5,790 | protected function conditionsContainIndexKey ( ) { if ( empty ( $ this -> where ) ) { return false ; } foreach ( $ this -> dynamoDbIndexKeys as $ key => $ name ) { if ( isset ( $ this -> where [ $ key ] ) ) { return $ key ; } } return false ; } | Checks if the conditions contains an index key . |
5,791 | protected static function getSpecificDynamoDbKey ( DynamoDbModel $ model , $ keyName , $ value ) { $ idKey = $ model -> marshalItem ( [ $ keyName => $ value , ] ) ; return [ $ keyName => $ idKey [ $ keyName ] ] ; } | Get a specific DynamoDb key . |
5,792 | protected static function getModelKey ( $ id , DynamoDbModel $ model ) { if ( is_array ( $ id ) ) { $ key = [ ] ; foreach ( $ id as $ name => $ value ) { $ specific_key = static :: getSpecificDynamoDbKey ( $ model , $ name , $ value ) ; foreach ( $ specific_key as $ keyName => $ keyValue ) { $ key [ $ keyName ] = $ key... | Get the key for this model whether composite or simple . |
5,793 | protected function getKeyAsArray ( ) { $ result = [ ] ; if ( ! empty ( $ this -> compositeKey ) ) { foreach ( $ this -> compositeKey as $ key ) { $ result [ $ key ] = $ this -> { $ key } ; } } else { $ result [ $ this -> getKeyName ( ) ] = $ this -> getKey ( ) ; } return $ result ; } | Get a key as array . |
5,794 | protected function setUnfillableAttributes ( array $ attributes = [ ] ) { if ( ! empty ( $ attributes ) ) { $ keysToFill = array_diff ( array_keys ( $ attributes ) , $ this -> fillable ) ; foreach ( $ keysToFill as $ key ) { $ this -> setAttribute ( $ key , $ attributes [ $ key ] ) ; } } } | Sets the unfillable attributes . |
5,795 | public function setAttributeValue ( $ name , $ arg ) { if ( property_exists ( $ this , $ name ) ) { $ this -> $ name = $ arg ; } else { $ this -> _attributes [ $ name ] = $ arg ; } } | Check property and set attribute value without type checking . |
5,796 | public function setAttribute ( $ name , $ args ) { if ( $ this -> isIgnoredAttribute ( $ name ) ) { return ; } if ( isset ( $ this -> _supportedAttributes [ $ name ] ) ) { $ c = count ( $ args ) ; $ t = $ this -> _supportedAttributes [ $ name ] ; if ( $ t != self :: ATTR_FLAG && $ c == 0 ) { throw new Exception ( 'Attr... | Check if the attribute is registered if it s registered the type registered will change the behavior of setting values . |
5,797 | public function registerCustomAttributes ( $ attributes ) { if ( is_string ( $ attributes ) ) { $ attributes = explode ( ' ' , $ attributes ) ; } $ this -> customAttributes = array_merge ( $ this -> customAttributes , ( array ) $ attributes ) ; return $ this ; } | Add attribute to customAttribute list |
5,798 | public function setAttributes ( $ attributes ) { foreach ( $ attributes as $ k => $ val ) { if ( $ this -> isIgnoredAttribute ( $ k ) ) { continue ; } if ( is_string ( $ val ) && strpos ( $ val , '+=' ) !== false ) { $ origValue = $ this -> getAttributeValue ( $ k ) ; if ( is_string ( $ origValue ) ) { $ origValue .= '... | Set attributes from array |
5,799 | public function renderAttributes ( ) { return $ this -> _renderAttributes ( $ this -> standardAttributes ) . $ this -> _renderAttributes ( $ this -> customAttributes ) . $ this -> _renderAttributes ( array_keys ( $ this -> _attributes ) ) ; } | Render attributes string |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.