idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
45,600 | public function preFlush ( PreFlushEventArgs $ args ) { $ scheduledInsertions = $ args -> getEntityManager ( ) -> getUnitOfWork ( ) -> getScheduledEntityInsertions ( ) ; foreach ( $ scheduledInsertions as $ entity ) { if ( $ entity instanceof CategoryInterface ) { $ this -> removeParentCategoryForRootCategory ( $ entity ) ; } } return $ this ; } | Pre flush event listener . |
45,601 | public function addActiveUrl ( $ activeUrl ) { $ activeUrls = json_decode ( $ this -> activeUrls , true ) ; $ activeUrls [ ] = $ activeUrl ; $ this -> activeUrls = json_encode ( $ activeUrls ) ; return $ this ; } | Add an active url . |
45,602 | public function removeActiveUrl ( $ activeUrl ) { $ activeUrls = json_decode ( $ this -> activeUrls , true ) ; $ positionFound = array_search ( $ activeUrl , $ activeUrls ) ; if ( $ positionFound ) { unset ( $ activeUrls [ $ positionFound ] ) ; $ this -> activeUrls = json_encode ( $ activeUrls ) ; } return $ this ; } | Remove an active url . |
45,603 | public function isActive ( $ currentUrl ) { $ activeUrls = $ this -> getActiveUrls ( ) ; return $ currentUrl == $ this -> url || ( is_array ( $ activeUrls ) && in_array ( $ currentUrl , $ this -> getActiveUrls ( ) ) ) ; } | Is active . |
45,604 | public function isExpanded ( $ currentUrl ) { if ( ! $ this -> subnodes instanceof Collection ) { return false ; } return $ this -> subnodes -> exists ( function ( $ _ , NodeInterface $ node ) use ( $ currentUrl ) { return $ node -> isActive ( $ currentUrl ) || $ node -> isExpanded ( $ currentUrl ) ; } ) ; } | Is expanded . |
45,605 | public function dispatchShippingCollectionEvent ( CartInterface $ cart ) { $ event = new ShippingCollectionEvent ( $ cart ) ; $ this -> eventDispatcher -> dispatch ( ElcodiShippingEvents :: SHIPPING_COLLECT , $ event ) ; return $ event -> getShippingMethods ( ) ; } | Dispatch shipping methods collection . |
45,606 | public function onAuthenticationSuccess ( AuthenticationEvent $ event ) { $ loggedUser = $ event -> getAuthenticationToken ( ) -> getUser ( ) ; $ cart = $ this -> cartWrapper -> get ( ) ; if ( ( $ loggedUser instanceof CustomerInterface ) && ( $ cart instanceof CartInterface && $ cart -> getId ( ) ) ) { $ cart -> setCustomer ( $ loggedUser ) ; $ this -> cartManager -> flush ( $ cart ) ; } } | Assign the Cart stored in session to the logged Customer . |
45,607 | public function create ( ) { $ classNamespace = $ this -> getEntityNamespace ( ) ; $ attribute = new $ classNamespace ( ) ; $ attribute -> setEnabled ( true ) -> setValues ( new ArrayCollection ( ) ) -> setCreatedAt ( $ this -> now ( ) ) ; return $ attribute ; } | Creates an Attribute instance . |
45,608 | public function getExchangeRateList ( ) { if ( ! empty ( $ this -> exchangeRateList ) ) { return $ this -> exchangeRateList ; } $ this -> exchangeRateList = [ ] ; $ currencyBase = $ this -> currencyRepository -> findOneBy ( [ 'iso' => $ this -> exchangeCurrencyIso , ] ) ; $ availableExchangeRates = $ this -> currencyExchangeRateRepository -> findBy ( [ 'sourceCurrency' => $ currencyBase , ] ) ; foreach ( $ availableExchangeRates as $ exchangeRate ) { $ targetCurrency = $ exchangeRate -> getTargetCurrency ( ) ; $ targetCurrencyIso = $ targetCurrency -> getIso ( ) ; $ this -> exchangeRateList [ $ targetCurrencyIso ] = [ 'rate' => $ exchangeRate -> getExchangeRate ( ) , 'currency' => $ targetCurrency , ] ; } return $ this -> exchangeRateList ; } | Given a the currency base returns a list of all exchange rates . |
45,609 | public function truncateOrderCoupons ( OrderInterface $ order ) { $ orderCoupons = $ this -> orderCouponRepository -> findOrderCouponsByOrder ( $ order ) ; if ( $ orderCoupons instanceof Collection ) { foreach ( $ orderCoupons as $ orderCoupon ) { $ this -> orderCouponObjectManager -> remove ( $ orderCoupon ) ; } $ this -> orderCouponObjectManager -> flush ( $ orderCoupons -> toArray ( ) ) ; } return $ this ; } | Purge existing OrderCoupons . |
45,610 | public function getAllParents ( ) { $ closestParents = $ this -> getParents ( ) ; $ allParents = [ ] ; foreach ( $ closestParents as $ parent ) { $ allParents = array_merge ( $ allParents , $ parent -> getAllParents ( ) ) ; } $ allParents = array_unique ( array_merge ( $ allParents , $ closestParents -> toArray ( ) ) ) ; return $ allParents ; } | Get all the parents . |
45,611 | public function addParent ( LocationInterface $ location ) { if ( ! $ this -> parents -> contains ( $ location ) ) { $ this -> parents -> add ( $ location ) ; $ location -> addChildren ( $ this ) ; } return $ this ; } | Add parent Location . |
45,612 | public function addChildren ( LocationInterface $ location ) { if ( ! $ this -> children -> contains ( $ location ) ) { $ this -> children -> add ( $ location ) ; } return $ this ; } | Get the children . |
45,613 | public function getAllCommentsSortedByParentAndIdAsc ( $ source , $ context ) { $ queryBuilder = $ this -> createQueryBuilder ( 'c' ) -> where ( 'c.source = :source' ) -> andWhere ( 'c.context = :context' ) -> andWhere ( 'c.enabled = :enabled' ) -> addOrderBy ( 'c.parent' , 'asc' ) -> addOrderBy ( 'c.id' , 'asc' ) -> setParameters ( [ 'source' => $ source , 'context' => $ context , 'enabled' => true , ] ) ; $ comments = $ queryBuilder -> getQuery ( ) -> getResult ( ) ; return new ArrayCollection ( $ comments ) ; } | Get all comments ordered by parent elements and position ascendant . |
45,614 | public function saveAddress ( AddressInterface $ address ) { if ( $ address -> getId ( ) ) { $ addressToSave = clone $ address ; $ addressToSave -> setId ( null ) ; $ this -> addressObjectManager -> refresh ( $ address ) ; $ this -> addressObjectManager -> persist ( $ addressToSave ) ; $ this -> addressObjectManager -> flush ( $ addressToSave ) ; $ this -> addressEventDispatcher -> dispatchAddressOnCloneEvent ( $ address , $ addressToSave ) ; return $ addressToSave ; } $ this -> addressObjectManager -> flush ( $ address ) ; return $ address ; } | Saves an address making a copy in case it was already persisted . Then returns the saved address . |
45,615 | public function addImage ( \ Elcodi \ Component \ Media \ Entity \ Interfaces \ ImageInterface $ image ) { $ this -> images -> add ( $ image ) ; return $ this ; } | Set add image . |
45,616 | public function removeImage ( \ Elcodi \ Component \ Media \ Entity \ Interfaces \ ImageInterface $ image ) { $ this -> images -> removeElement ( $ image ) ; return $ this ; } | Get if entity is enabled . |
45,617 | public function getSortedImages ( ) { $ imagesSort = explode ( ',' , $ this -> getImagesSort ( ) ) ; $ orderCollection = array_reverse ( $ imagesSort ) ; $ imagesCollection = $ this -> getImages ( ) -> toArray ( ) ; usort ( $ imagesCollection , function ( \ Elcodi \ Component \ Media \ Entity \ Interfaces \ ImageInterface $ a , \ Elcodi \ Component \ Media \ Entity \ Interfaces \ ImageInterface $ b ) use ( $ orderCollection ) { $ aPos = array_search ( $ a -> getId ( ) , $ orderCollection ) ; $ bPos = array_search ( $ b -> getId ( ) , $ orderCollection ) ; return ( $ aPos < $ bPos ) ? 1 : - 1 ; } ) ; return new ArrayCollection ( $ imagesCollection ) ; } | Get sorted images . |
45,618 | public function setImages ( \ Doctrine \ Common \ Collections \ ArrayCollection $ images ) { $ this -> images = $ images ; return $ this ; } | Set images . |
45,619 | private function getCustomerFromToken ( ) { if ( ! ( $ this -> tokenStorage instanceof TokenStorageInterface ) ) { return null ; } $ token = $ this -> tokenStorage -> getToken ( ) ; if ( ! ( $ token instanceof TokenInterface ) ) { return null ; } $ customer = $ token -> getUser ( ) ; if ( ! ( $ customer instanceof CustomerInterface ) ) { return null ; } return $ customer ; } | Return the current user from security context . |
45,620 | public function create ( ) { $ zeroPrice = $ this -> createZeroAmountMoney ( ) ; $ classNamespace = $ this -> getEntityNamespace ( ) ; $ variant = new $ classNamespace ( ) ; $ variant -> setSku ( '' ) -> setStock ( 0 ) -> setPrice ( $ zeroPrice ) -> setReducedPrice ( $ zeroPrice ) -> setImages ( new ArrayCollection ( ) ) -> setOptions ( new ArrayCollection ( ) ) -> setWidth ( 0 ) -> setHeight ( 0 ) -> setWidth ( 0 ) -> setDepth ( 0 ) -> setWeight ( 0 ) -> setShowInHome ( false ) -> setImagesSort ( '' ) -> setEnabled ( true ) -> setCreatedAt ( $ this -> now ( ) ) ; return $ variant ; } | Creates and returns a pristine Variant instance . |
45,621 | public function referrerIsSearchEngine ( ) { $ referrerHostExploded = explode ( '.' , $ this -> getReferrerDomain ( ) ) ; $ numberOfPieces = count ( $ referrerHostExploded ) ; $ positionToCheck = $ numberOfPieces - 2 ; if ( ! isset ( $ referrerHostExploded [ $ positionToCheck ] ) ) { return false ; } if ( strlen ( $ referrerHostExploded [ $ positionToCheck ] ) <= 3 ) { -- $ positionToCheck ; if ( ! isset ( $ referrerHostExploded [ $ positionToCheck ] ) ) { return false ; } } return in_array ( $ referrerHostExploded [ $ positionToCheck ] , [ 'baidu' , 'bing' , 'bleikko' , 'duckduckgo' , 'exalead' , 'gigablast' , 'google' , 'munax' , 'qwant' , 'sogou' , 'yahoo' , 'yandex' , ] ) ; } | Referrer is search engine . |
45,622 | private function buildUrlByMethodName ( $ method , array $ parameters ) { $ url = $ this -> apiUrls -> $ method ( ) ; return $ this -> host ? $ this -> buildUrlWithHost ( $ url , $ parameters ) : $ this -> buildUrlWithoutHost ( $ url , $ parameters ) ; } | Given a method of the ApiUrls value object and a parameters for the route construction return url . |
45,623 | private function buildUrlWithHost ( $ url , array $ parameters ) { return trim ( $ this -> host , '/' ) . '/' . ltrim ( $ this -> urlGeneratorInterface -> generate ( $ url , $ parameters , UrlGeneratorInterface :: ABSOLUTE_PATH ) , '/' ) ; } | Given an url return the complete route using host . |
45,624 | private function buildUrlWithoutHost ( $ url , array $ parameters ) { return $ this -> urlGeneratorInterface -> generate ( $ url , $ parameters , UrlGeneratorInterface :: ABSOLUTE_URL ) ; } | Given an url return the complete route in ab absolute way . |
45,625 | private function resolveApiUrl ( $ url ) { $ client = new Client ( [ 'defaults' => [ 'timeout' => 5 , ] , ] ) ; $ response = $ client -> get ( $ url ) ; $ responseStatusCode = $ response -> getStatusCode ( ) ; if ( 404 == $ responseStatusCode ) { throw new EntityNotFoundException ( ) ; } if ( 500 == $ responseStatusCode ) { throw new HttpException ( 'Http exception' ) ; } return $ response -> json ( [ 'object' => false ] ) ; } | Call given url unpack the response and look for possible api exceptions . |
45,626 | private function buildLocations ( array $ data ) { $ locationInstances = [ ] ; foreach ( $ data as $ locationData ) { $ locationInstances [ ] = $ this -> buildLocation ( $ locationData ) ; } return $ locationInstances ; } | Build a new set of Location instances given some data . |
45,627 | public function loadMenuByCode ( $ menuCode ) { $ menu = $ this -> loadFromMemory ( $ menuCode ) ; if ( ! ( $ menu instanceof MenuInterface ) ) { $ key = $ this -> getCacheKey ( $ menuCode ) ; $ menu = $ this -> loadFromCache ( $ key ) ; if ( ! ( $ menu instanceof MenuInterface ) ) { $ menu = $ this -> buildMenuFromRepository ( $ menuCode ) ; $ this -> applyMenuChangers ( $ menu , ElcodiMenuStages :: BEFORE_CACHE ) ; $ this -> saveToCache ( $ key , $ menu ) ; } $ this -> applyMenuChangers ( $ menu , ElcodiMenuStages :: AFTER_CACHE ) ; $ this -> saveToMemory ( $ menu ) ; } return $ menu ; } | Load menu hydration given the code . |
45,628 | private function loadFromMemory ( $ menuCode ) { return isset ( $ this -> menus [ $ menuCode ] ) ? $ this -> menus [ $ menuCode ] : null ; } | Try to get menu configuration from memory . |
45,629 | private function loadFromCache ( $ key ) { $ encoded = ( string ) $ this -> cache -> fetch ( $ key ) ; try { return is_string ( $ encoded ) ? $ this -> encoder -> decode ( $ encoded ) : null ; } catch ( Exception $ e ) { } return null ; } | Try to get menu configuration from cache . |
45,630 | private function applyMenuChangers ( MenuInterface $ menu , $ stage ) { foreach ( $ this -> menuChangers as $ menuChanger ) { $ menuChanger -> applyChange ( $ menu , $ stage ) ; } return $ this ; } | Apply menu changers to Menu . |
45,631 | public function setAbsolutePrice ( MoneyInterface $ amount ) { $ this -> absolutePriceAmount = $ amount -> getAmount ( ) ; $ this -> absolutePriceCurrency = $ amount -> getCurrency ( ) ; return $ this ; } | Set absolute price . |
45,632 | public function setMinimumPurchase ( MoneyInterface $ amount ) { $ this -> minimumPurchaseAmount = $ amount -> getAmount ( ) ; $ this -> minimumPurchaseCurrency = $ amount -> getCurrency ( ) ; return $ this ; } | Set minimum purchase . |
45,633 | public function makeUse ( ) { ++ $ this -> used ; if ( $ this -> count > 0 && $ this -> count <= $ this -> used ) { $ this -> enabled = false ; } return $ this ; } | Increment used variable by one and disables it if there are no more available units . |
45,634 | public function createOrderCouponByCoupon ( OrderCouponOnApplyEvent $ event ) { $ orderCoupon = $ this -> couponToOrderCouponTransformer -> createOrderCouponByCoupon ( $ event -> getOrder ( ) , $ event -> getCoupon ( ) ) ; $ event -> setOrderCoupon ( $ orderCoupon ) ; } | Event subscribed on OrderCoupon applied into an order . |
45,635 | public function createOrderFromCart ( CartInterface $ cart ) { $ this -> orderEventDispatcher -> dispatchOrderPreCreatedEvent ( $ cart ) ; $ order = $ cart -> getOrder ( ) instanceof OrderInterface ? $ cart -> getOrder ( ) : $ this -> orderFactory -> create ( ) ; $ cart -> setOrder ( $ order ) ; $ orderLines = $ this -> cartLineOrderLineTransformer -> createOrderLinesByCartLines ( $ order , $ cart -> getCartLines ( ) ) ; $ order -> setCustomer ( $ cart -> getCustomer ( ) ) -> setCart ( $ cart ) -> setQuantity ( $ cart -> getTotalItemNumber ( ) ) -> setPurchasableAmount ( $ cart -> getPurchasableAmount ( ) ) -> setShippingAmount ( $ cart -> getShippingAmount ( ) ) -> setAmount ( $ cart -> getAmount ( ) ) -> setHeight ( $ cart -> getHeight ( ) ) -> setWidth ( $ cart -> getWidth ( ) ) -> setDepth ( $ cart -> getDepth ( ) ) -> setWeight ( $ cart -> getWeight ( ) ) -> setBillingAddress ( $ cart -> getBillingAddress ( ) ) -> setDeliveryAddress ( $ cart -> getDeliveryAddress ( ) ) -> setOrderLines ( $ orderLines ) ; $ couponAmount = $ cart -> getCouponAmount ( ) ; if ( $ couponAmount instanceof MoneyInterface ) { $ order -> setCouponAmount ( $ couponAmount ) ; } $ this -> orderEventDispatcher -> dispatchOrderOnCreatedEvent ( $ cart , $ order ) ; return $ order ; } | This method creates a Order given a Cart . |
45,636 | public function validateEmptyShippingAmount ( CartInterface $ cart ) { $ shippingAmount = $ cart -> getShippingAmount ( ) ; if ( ! ( $ shippingAmount instanceof MoneyInterface ) ) { $ cart -> setShippingAmount ( $ this -> emptyMoneyWrapper -> get ( ) ) ; } } | If the cart s shipping amount is not defined then put an empty Money value . |
45,637 | public function duplicateCoupon ( CouponInterface $ coupon , DateTime $ dateFrom = null ) { if ( null === $ dateFrom ) { $ dateFrom = $ this -> dateTimeFactory -> create ( ) ; } $ dateTo = null ; if ( $ coupon -> getValidTo ( ) instanceof DateTime ) { $ interval = $ coupon -> getValidFrom ( ) -> diff ( $ coupon -> getValidTo ( ) ) ; $ dateTo = clone $ dateFrom ; $ dateTo -> add ( $ interval ) ; } $ couponGenerated = $ this -> couponFactory -> create ( ) ; $ couponCode = $ this -> couponCodeGenerator -> generate ( 10 ) ; $ couponGenerated -> setCode ( $ couponCode ) -> setName ( $ coupon -> getName ( ) ) -> setType ( $ coupon -> getType ( ) ) -> setPrice ( $ coupon -> getPrice ( ) ) -> setDiscount ( $ coupon -> getDiscount ( ) ) -> setCount ( $ coupon -> getCount ( ) ) -> setPriority ( $ coupon -> getPriority ( ) ) -> setMinimumPurchase ( $ coupon -> getMinimumPurchase ( ) ) -> setValidFrom ( $ dateFrom ) -> setValidTo ( $ dateTo ) -> setValue ( $ coupon -> getValue ( ) ) -> setRule ( $ coupon -> getRule ( ) ) -> setEnforcement ( $ coupon -> getEnforcement ( ) ) -> setEnabled ( true ) ; return $ couponGenerated ; } | Creates a new coupon instance given an existing Coupon as reference . |
45,638 | public function checkCoupon ( CouponInterface $ coupon ) { if ( ! $ this -> IsActive ( $ coupon ) ) { throw new CouponNotActiveException ( ) ; } if ( ! $ this -> canBeUsed ( $ coupon ) ) { throw new CouponAppliedException ( ) ; } return true ; } | Checks whether a coupon can be applied or not . |
45,639 | private function isActive ( CouponInterface $ coupon , \ DateTime $ now = null ) { if ( ! $ coupon -> isEnabled ( ) ) { return false ; } $ now = $ now ? : $ this -> dateTimeFactory -> create ( ) ; if ( $ coupon -> getValidFrom ( ) > $ now ) { return false ; } $ validTo = $ coupon -> getValidTo ( ) ; if ( $ validTo && $ now > $ validTo ) { return false ; } return true ; } | Check if a coupon is currently active . |
45,640 | private function canBeUsed ( CouponInterface $ coupon ) { $ count = $ coupon -> getCount ( ) ; if ( $ count === 0 ) { return true ; } if ( $ coupon -> getUsed ( ) < $ count ) { return true ; } return false ; } | Check if a coupon can be currently used . |
45,641 | public function logTransition ( Transition $ transition ) { $ this -> logger -> info ( 'Transition {transition_name} in machine "{machine_id}" from "{state_from}" to "{state_to}"' , [ 'transition_name' => $ transition -> getName ( ) , 'machine_id' => $ this -> machine -> getId ( ) , 'state_from' => $ transition -> getStart ( ) -> getName ( ) , 'state_to' => $ transition -> getFinal ( ) -> getName ( ) , ] ) ; } | Log transition . |
45,642 | public function dispatchImagePreUploadEvent ( ImageInterface $ image ) { $ imageUploadedEvent = new ImageUploadedEvent ( $ image ) ; $ this -> eventDispatcher -> dispatch ( ElcodiMediaEvents :: IMAGE_PREUPLOAD , $ imageUploadedEvent ) ; return $ this ; } | Create image pre uploaded event . |
45,643 | public function dispatchImageOnUploadEvent ( ImageInterface $ image ) { $ imageUploadedEvent = new ImageUploadedEvent ( $ image ) ; $ this -> eventDispatcher -> dispatch ( ElcodiMediaEvents :: IMAGE_ONUPLOAD , $ imageUploadedEvent ) ; return $ this ; } | Create image on uploaded event . |
45,644 | public function validateCartCouponRules ( CartInterface $ cart , CouponInterface $ coupon ) { $ rule = $ coupon -> getRule ( ) ; if ( null === $ rule ) { return ; } try { $ isValid = $ this -> ruleManager -> evaluate ( $ rule , [ 'cart' => $ cart , 'coupon' => $ coupon , ] ) ; if ( ! $ isValid ) { throw new CouponRulesNotValidateException ( ) ; } return ; } catch ( Exception $ e ) { } throw new CouponRulesNotValidateException ( ) ; } | Checks if given Coupon is valid . To determine its validity this service will evaluate all rules if there are any . |
45,645 | public function dispatchOrderCouponOnApplyEvent ( OrderInterface $ cart , CouponInterface $ coupon ) { $ event = new OrderCouponOnApplyEvent ( $ cart , $ coupon ) ; $ this -> eventDispatcher -> dispatch ( ElcodiCartCouponEvents :: ORDER_COUPON_ONAPPLY , $ event ) ; } | Dispatch event just before a coupon is applied into an Order . |
45,646 | public function build ( $ basepath , $ language = null ) { $ sitemapElements = [ ] ; foreach ( $ this -> sitemapElementGenerators as $ sitemapElementGenerator ) { $ sitemapElements = array_merge ( $ sitemapElements , $ sitemapElementGenerator -> generateElements ( $ language ) ) ; } $ data = $ this -> sitemapRenderer -> render ( $ sitemapElements , $ basepath ) ; return $ data ; } | Build sitemap builder . |
45,647 | public function addLocation ( $ id , $ name , $ code , $ type , LocationInterface $ parent = null ) { $ location = isset ( $ this -> locations [ $ id ] ) ? $ this -> locations [ $ id ] : $ this -> locationFactory -> create ( ) -> setId ( $ id ) -> setName ( $ name ) -> setCode ( $ code ) -> setType ( $ type ) ; if ( $ parent instanceof LocationInterface ) { $ location -> addParent ( $ parent ) ; } $ this -> locations [ $ id ] = $ location ; return $ location ; } | Given a location information create a new Location . |
45,648 | public function dump ( $ basepath ) { foreach ( $ this -> sitemapDumpers as $ sitemapDumper ) { if ( is_array ( $ this -> languages ) ) { foreach ( $ this -> languages as $ language ) { $ sitemapDumper -> dump ( $ basepath , $ language ) ; } } else { $ sitemapDumper -> dump ( $ basepath ) ; } } return $ this ; } | Build full profile . |
45,649 | public function notifyCouponUsage ( CouponInterface $ coupon ) { $ couponUsedEvent = new CouponOnUsedEvent ( $ coupon ) ; $ this -> eventDispatcher -> dispatch ( ElcodiCouponEvents :: COUPON_USED , $ couponUsedEvent ) ; return $ this ; } | Notify Coupon usage . |
45,650 | public function createOrderCouponByCoupon ( OrderInterface $ order , CouponInterface $ coupon ) { $ orderCoupon = $ this -> orderCouponFactory -> create ( ) -> setOrder ( $ order ) -> setCoupon ( $ coupon ) -> setAmount ( $ coupon -> getAbsolutePrice ( ) ) -> setName ( $ coupon -> getName ( ) ) -> setCode ( $ coupon -> getCode ( ) ) ; $ this -> orderCouponObjectManager -> persist ( $ orderCoupon ) ; $ this -> orderCouponObjectManager -> flush ( $ orderCoupon ) ; $ this -> couponEventDispatcher -> notifyCouponUsage ( $ coupon ) ; return $ orderCoupon ; } | Creates a new OrderCoupon instance given a Coupon and saves it into the persistence layer . |
45,651 | public function getBundleNamespaceRoot ( ) { $ bundleParts = explode ( '\\' , $ this -> getNamespace ( ) ) ; unset ( $ bundleParts [ count ( $ bundleParts ) - 1 ] ) ; return implode ( '\\' , $ bundleParts ) ; } | Get Bundle name . |
45,652 | public function setFieldValues ( array $ fieldValues ) { foreach ( $ fieldValues as $ field => $ fieldValue ) { $ this -> configuration -> setFieldValue ( $ field , $ fieldValue ) ; } return $ this ; } | Get an array with all field values indexed by the field name . |
45,653 | public function isUsable ( array $ requiredFields = [ ] ) { return array_reduce ( $ requiredFields , function ( $ canBeUsed , $ checkableField ) { return $ canBeUsed && $ this -> hasField ( $ checkableField ) && ( false === $ this -> getField ( $ checkableField ) [ 'required' ] || $ this -> getFieldValue ( $ checkableField ) ) ; } , $ this -> isEnabled ( ) ) ; } | Plugin is usable . |
45,654 | public function merge ( Plugin $ newPlugin ) { if ( $ newPlugin -> getNamespace ( ) !== $ this -> getNamespace ( ) ) { throw new RuntimeException ( 'Both plugins cannot be merged' ) ; } $ this -> configuration -> merge ( $ newPlugin -> getConfiguration ( ) ) ; return $ this ; } | Merge this plugin instance with a new one and saves the result in this instance . |
45,655 | public static function create ( $ namespace , $ type , $ category , PluginConfiguration $ configuration , $ enabled ) { return new self ( $ namespace , $ type , $ category , $ configuration , $ enabled ) ; } | Return new plugin instance . |
45,656 | public function create ( ) { $ classNamespace = $ this -> getEntityNamespace ( ) ; $ comment = new $ classNamespace ( ) ; $ comment -> setParent ( null ) -> setChildren ( new ArrayCollection ( ) ) -> setEnabled ( true ) -> setCreatedAt ( $ this -> now ( ) ) ; return $ comment ; } | Creates an instance of Comment . |
45,657 | public function create ( EntityTranslationProviderInterface $ entityTranslationProvider , array $ configuration , $ fallback ) { return new $ this -> entityNamespace ( $ entityTranslationProvider , $ configuration , $ fallback ) ; } | Creates an instance of a translator . |
45,658 | public function compile ( ) { $ nodesVisited = [ ] ; $ this -> checkTransitionsConfiguration ( $ this -> configuration ) -> checkPointOfEntry ( $ this -> configuration , $ this -> pointOfEntry ) -> checkCycles ( $ this -> configuration , $ this -> pointOfEntry , $ nodesVisited ) ; $ this -> transitionChain = $ this -> compileTransitions ( $ this -> configuration ) ; $ this -> checkTransitionDuplicates ( $ this -> transitionChain ) -> checkStates ( $ this -> transitionChain ) ; $ machine = $ this -> machineFactory -> generate ( $ this -> machineId , $ this -> transitionChain , $ this -> pointOfEntry ) ; return $ machine ; } | Compile machine . |
45,659 | private function checkTransitionsConfiguration ( array $ configuration ) { foreach ( $ configuration as $ transitionConfiguration ) { if ( is_array ( $ transitionConfiguration ) && ( count ( $ transitionConfiguration ) === 3 ) && isset ( $ transitionConfiguration [ 0 ] ) && is_string ( $ transitionConfiguration [ 0 ] ) && $ transitionConfiguration [ 0 ] && isset ( $ transitionConfiguration [ 1 ] ) && is_string ( $ transitionConfiguration [ 1 ] ) && $ transitionConfiguration [ 1 ] && isset ( $ transitionConfiguration [ 2 ] ) && is_string ( $ transitionConfiguration [ 2 ] ) && $ transitionConfiguration [ 2 ] ) { return $ this ; } } throw new TransitionNotValidException ( ) ; } | Given an array of configuration checks that all data is prepared for being compiled . |
45,660 | private function checkPointOfEntry ( array $ configuration , $ pointOfEntry ) { foreach ( $ configuration as $ transitionConfiguration ) { if ( $ transitionConfiguration [ 0 ] === $ pointOfEntry ) { return $ this ; } } throw new InvalidPointOfEntryException ( $ pointOfEntry ) ; } | Check point of entry . |
45,661 | private function checkCycles ( array $ configuration , $ node , array & $ nodesVisited ) { if ( in_array ( $ node , $ nodesVisited ) ) { if ( ! $ this -> canBeCyclic ) { throw new CyclesNotAllowedException ( ) ; } return $ this ; } $ nodesVisited [ ] = $ node ; foreach ( $ configuration as $ transitionConfiguration ) { if ( $ transitionConfiguration [ 0 ] === $ node ) { $ this -> checkCycles ( $ configuration , $ transitionConfiguration [ 2 ] , $ nodesVisited ) ; } } return $ this ; } | Check cycles . |
45,662 | private function compileTransitions ( array $ configuration ) { $ transitionChain = TransitionChain :: create ( ) ; foreach ( $ configuration as $ transitionConfiguration ) { list ( $ startStateName , $ transitionName , $ finalStateName ) = $ transitionConfiguration ; $ startState = new State ( $ startStateName ) ; $ finalState = new State ( $ finalStateName ) ; $ transition = new Transition ( $ transitionName , $ startState , $ finalState ) ; $ transitionChain -> addTransition ( $ transition ) ; } return $ transitionChain ; } | Compile transitions and return structure compiled . |
45,663 | private function checkTransitionDuplicates ( TransitionChain $ transitionChain ) { $ states = [ ] ; foreach ( $ transitionChain -> getTransitions ( ) as $ transition ) { $ startingStateName = $ transition -> getStart ( ) -> getName ( ) ; $ transitionName = $ transition -> getName ( ) ; if ( isset ( $ states [ $ startingStateName ] ) ) { if ( isset ( $ states [ $ startingStateName ] [ $ transitionName ] ) ) { throw new InconsistentTransitionConfigurationException ( $ startingStateName , $ transitionName ) ; } } else { $ states [ $ startingStateName ] = [ ] ; } $ states [ $ startingStateName ] [ $ transitionName ] = true ; } return $ this ; } | Check transitions duplicates . |
45,664 | private function checkStates ( TransitionChain $ transitionChain ) { foreach ( $ transitionChain -> getTransitions ( ) as $ transition ) { $ initialStateName = $ transition -> getStart ( ) -> getName ( ) ; if ( $ initialStateName === $ this -> pointOfEntry ) { continue ; } if ( ! $ this -> transitionChain -> getTransitionsByFinalState ( $ initialStateName ) ) { throw new StateNotValidException ( $ initialStateName ) ; } } return $ this ; } | Compile next states of each state . |
45,665 | protected function postLoad ( array $ config , ContainerBuilder $ container ) { $ this -> loadBlocks ( $ config [ 'blocks' ] , $ container ) -> loadStatics ( $ config [ 'statics' ] , $ container ) -> loadBuilders ( $ config [ 'builders' ] , $ container ) -> loadDumpers ( $ config [ 'builders' ] , $ container ) -> loadProfiles ( $ config [ 'profiles' ] , $ container ) ; } | Hook after load the full container . |
45,666 | protected function loadBlocks ( array $ blocks , ContainerBuilder $ container ) { foreach ( $ blocks as $ blockName => $ block ) { $ container -> register ( 'elcodi.sitemap_element_provider.entity_' . $ blockName , 'Elcodi\Component\Sitemap\Element\EntitySitemapElementProvider' ) -> addArgument ( new Reference ( $ block [ 'repository_service' ] ) ) -> addArgument ( $ block [ 'method' ] ) -> addArgument ( $ block [ 'arguments' ] ) -> setPublic ( false ) ; $ container -> register ( 'elcodi.sitemap_element_generator.entity_' . $ blockName , 'Elcodi\Component\Sitemap\Element\EntitySitemapElementGenerator' ) -> addArgument ( new Reference ( 'elcodi.factory.sitemap_element' ) ) -> addArgument ( new Reference ( $ block [ 'transformer' ] ) ) -> addArgument ( new Reference ( 'elcodi.sitemap_element_provider.entity_' . $ blockName ) ) -> addArgument ( $ block [ 'changeFrequency' ] ) -> addArgument ( $ block [ 'priority' ] ) -> setPublic ( false ) ; } return $ this ; } | Load blocks . |
45,667 | protected function loadStatics ( array $ statics , ContainerBuilder $ container ) { foreach ( $ statics as $ staticName => $ static ) { $ container -> register ( 'elcodi.sitemap_element_generator.static_' . $ staticName , 'Elcodi\Component\Sitemap\Element\StaticSitemapElementGenerator' ) -> addArgument ( new Reference ( 'elcodi.factory.sitemap_element' ) ) -> addArgument ( new Reference ( $ static [ 'transformer' ] ) ) -> addArgument ( $ staticName ) -> addArgument ( $ static [ 'changeFrequency' ] ) -> addArgument ( $ static [ 'priority' ] ) -> setPublic ( false ) ; } return $ this ; } | Load statics . |
45,668 | protected function loadBuilders ( array $ builders , ContainerBuilder $ container ) { foreach ( $ builders as $ builderName => $ builder ) { $ definition = $ container -> register ( 'elcodi.sitemap_builder.' . $ builderName , 'Elcodi\Component\Sitemap\Builder\SitemapBuilder' ) -> addArgument ( new Reference ( $ builder [ 'renderer' ] ) ) -> addArgument ( $ builder [ 'path' ] ) -> setPublic ( true ) ; $ this -> addBuilderElements ( $ definition , $ builder [ 'statics' ] , 'static' ) -> addBuilderElements ( $ definition , $ builder [ 'blocks' ] , 'entity' ) ; } return $ this ; } | Load builders . |
45,669 | protected function addBuilderElements ( Definition $ builderDefinition , array $ elements , $ elementType ) { foreach ( $ elements as $ blockReference ) { $ builderDefinition -> addMethodCall ( 'addSitemapElementGenerator' , [ new Reference ( 'elcodi.sitemap_element_generator.' . $ elementType . '_' . $ blockReference ) ] ) ; } return $ this ; } | Load builder blocks . |
45,670 | protected function loadDumpers ( array $ builders , ContainerBuilder $ container ) { foreach ( $ builders as $ builderName => $ builder ) { $ container -> register ( 'elcodi.sitemap_dumper.' . $ builderName , 'Elcodi\Component\Sitemap\Dumper\SitemapDumper' ) -> addArgument ( new Reference ( 'elcodi.sitemap_builder.' . $ builderName ) ) -> addArgument ( new Reference ( $ builder [ 'dumper' ] ) ) -> addArgument ( $ builder [ 'path' ] ) -> setPublic ( true ) ; } return $ this ; } | Load dumpers . |
45,671 | protected function loadProfiles ( array $ profiles , ContainerBuilder $ container ) { foreach ( $ profiles as $ profileName => $ profile ) { $ definition = $ container -> register ( 'elcodi.sitemap_profile.' . $ profileName , 'Elcodi\Component\Sitemap\Profile\SitemapProfile' ) -> addArgument ( new Reference ( $ profile [ 'languages' ] ) ) -> setPublic ( true ) ; foreach ( $ profile [ 'builders' ] as $ builderReference ) { $ definition -> addMethodCall ( 'addSitemapDumper' , [ new Reference ( 'elcodi.sitemap_dumper.' . $ builderReference ) ] ) ; } } return $ this ; } | Load profiles . |
45,672 | public function create ( $ location , $ lastModification = null , $ changeFrequency = null , $ priority = null ) { return new SitemapElement ( $ location , $ lastModification , $ changeFrequency , $ priority ) ; } | Create new SitemapElement . |
45,673 | public function dispatchAddressOnCloneEvent ( AddressInterface $ originalAddress , AddressInterface $ clonedAddress ) { $ this -> eventDispatcher -> dispatch ( ElcodiGeoEvents :: ADDRESS_ONCLONE , new AddressOnCloneEvent ( $ originalAddress , $ clonedAddress ) ) ; return $ this ; } | Dispatches the address on clone event . |
45,674 | public function loadOrderShippingMethod ( OrderOnCreatedEvent $ event ) { $ this -> orderShippingMethodLoader -> loadOrderShippingMethod ( $ event -> getCart ( ) , $ event -> getOrder ( ) ) ; } | Load cart shipping amount . |
45,675 | protected function appendTemplate ( $ template , \ Elcodi \ Component \ Plugin \ EventDispatcher \ Interfaces \ EventInterface $ event , \ Elcodi \ Component \ Plugin \ Entity \ Plugin $ plugin , array $ extraContextParams = [ ] ) { $ event -> setContent ( $ event -> getContent ( ) . $ this -> twig -> render ( $ template , array_merge ( $ event -> getContext ( ) , [ 'plugin' => $ plugin ] , $ extraContextParams ) ) ) ; } | Render a template and append to the current content . |
45,676 | public function printUrl ( $ route ) { if ( empty ( $ route ) ) { return '' ; } try { $ url = $ this -> urlGenerator -> generate ( $ route ) ; } catch ( ExceptionInterface $ e ) { $ url = ( string ) $ route ; } return $ url ; } | Returns an URL given a string representing a route . |
45,677 | public function load ( ObjectManager $ objectManager ) { $ attributeDirector = $ this -> getDirector ( 'attribute' ) ; $ attributeValueDirector = $ this -> getDirector ( 'attribute_value' ) ; $ sizeAttribute = $ attributeDirector -> create ( ) -> setName ( 'Size' ) -> setEnabled ( true ) ; $ attributeDirector -> save ( $ sizeAttribute ) ; $ this -> addReference ( 'attribute-size' , $ sizeAttribute ) ; $ smallValue = $ attributeValueDirector -> create ( ) -> setValue ( 'Small' ) -> setAttribute ( $ sizeAttribute ) ; $ attributeValueDirector -> save ( $ smallValue ) ; $ this -> addReference ( 'value-size-small' , $ smallValue ) ; $ mediumValue = $ attributeValueDirector -> create ( ) -> setValue ( 'Medium' ) -> setAttribute ( $ sizeAttribute ) ; $ attributeValueDirector -> save ( $ mediumValue ) ; $ this -> addReference ( 'value-size-medium' , $ mediumValue ) ; $ largeValue = $ attributeValueDirector -> create ( ) -> setValue ( 'Large' ) -> setAttribute ( $ sizeAttribute ) ; $ attributeValueDirector -> save ( $ largeValue ) ; $ this -> addReference ( 'value-size-large' , $ largeValue ) ; $ colorAttribute = $ attributeDirector -> create ( ) -> setName ( 'Color' ) -> setEnabled ( true ) ; $ attributeDirector -> save ( $ colorAttribute ) ; $ this -> addReference ( 'attribute-color' , $ colorAttribute ) ; $ blueValue = $ attributeValueDirector -> create ( ) -> setValue ( 'Blue' ) -> setAttribute ( $ colorAttribute ) ; $ attributeValueDirector -> save ( $ blueValue ) ; $ this -> addReference ( 'value-color-blue' , $ blueValue ) ; $ whiteValue = $ attributeValueDirector -> create ( ) -> setValue ( 'White' ) -> setAttribute ( $ colorAttribute ) ; $ attributeValueDirector -> save ( $ whiteValue ) ; $ this -> addReference ( 'value-color-white' , $ whiteValue ) ; $ redValue = $ attributeValueDirector -> create ( ) -> setValue ( 'Red' ) -> setAttribute ( $ colorAttribute ) ; $ attributeValueDirector -> save ( $ redValue ) ; $ this -> addReference ( 'value-color-red' , $ redValue ) ; } | Loads sample fixtures for Attribute entities . |
45,678 | public function getOneById ( CartInterface $ cart , $ shippingMethodId ) { $ shippingMethods = $ this -> get ( $ cart ) ; return array_reduce ( $ shippingMethods , function ( $ foundShippingMethod , ShippingMethod $ shippingMethod ) use ( $ shippingMethodId ) { return ( $ shippingMethodId === $ shippingMethod -> getId ( ) ) ? $ shippingMethod : $ foundShippingMethod ; } , null ) ; } | Get loaded shipping method given its id . |
45,679 | public function generate ( $ machineId , TransitionChain $ transitionChain , $ pointOfEntry ) { $ machine = new Machine ( $ machineId , $ transitionChain , $ pointOfEntry ) ; return $ machine ; } | Generate new machine . |
45,680 | public function dispatchSubscribeEvent ( NewsletterSubscriptionInterface $ newsletterSubscription ) { $ newsletterSubscriptionEvent = new NewsletterSubscriptionEvent ( $ newsletterSubscription ) ; $ this -> eventDispatcher -> dispatch ( ElcodiNewsletterEvents :: NEWSLETTER_SUBSCRIBE , $ newsletterSubscriptionEvent ) ; } | Dispatch subscription event . |
45,681 | public function dispatchUnsubscribeEvent ( NewsletterSubscriptionInterface $ newsletterSubscription ) { $ newsletterSubscriptionEvent = new NewsletterUnsubscriptionEvent ( $ newsletterSubscription ) ; $ this -> eventDispatcher -> dispatch ( ElcodiNewsletterEvents :: NEWSLETTER_UNSUBSCRIBE , $ newsletterSubscriptionEvent ) ; } | Dispatch unsubscription event . |
45,682 | public function create ( ) { $ classNamespace = $ this -> getEntityNamespace ( ) ; $ vote = new $ classNamespace ( ) ; $ vote -> setCreatedAt ( $ this -> now ( ) ) ; return $ vote ; } | Creates an instance of Vote . |
45,683 | private function parser ( string $ data , callable $ cast = null , string $ delimiter = ',' ) : \ Generator { if ( $ data [ 0 ] !== '{' || \ substr ( $ data , - 1 ) !== '}' ) { throw new ParseException ( "Missing opening or closing brackets" ) ; } $ data = \ ltrim ( \ substr ( $ data , 1 ) ) ; do { if ( $ data === '' ) { throw new ParseException ( "Missing closing bracket" ) ; } if ( $ data [ 0 ] === '{' ) { $ parser = $ this -> parser ( $ data , $ cast , $ delimiter ) ; yield \ iterator_to_array ( $ parser ) ; $ data = $ parser -> getReturn ( ) ; $ end = $ this -> trim ( $ data , 0 , $ delimiter ) ; continue ; } if ( $ data [ 0 ] === '"' ) { for ( $ position = 1 ; isset ( $ data [ $ position ] ) ; ++ $ position ) { if ( $ data [ $ position ] === '\\' ) { ++ $ position ; continue ; } if ( $ data [ $ position ] === '"' ) { break ; } } if ( ! isset ( $ data [ $ position ] ) ) { throw new ParseException ( "Could not find matching quote in quoted value" ) ; } $ yield = \ stripslashes ( \ substr ( $ data , 1 , $ position - 1 ) ) ; $ end = $ this -> trim ( $ data , $ position + 1 , $ delimiter ) ; } else { $ position = 0 ; while ( isset ( $ data [ $ position ] ) && $ data [ $ position ] !== $ delimiter && $ data [ $ position ] !== '}' ) { ++ $ position ; } $ yield = \ trim ( \ substr ( $ data , 0 , $ position ) ) ; $ end = $ this -> trim ( $ data , $ position , $ delimiter ) ; if ( \ strcasecmp ( $ yield , "NULL" ) === 0 ) { yield null ; continue ; } } yield $ cast ? $ cast ( $ yield ) : $ yield ; } while ( $ end !== '}' ) ; return $ data ; } | Recursive generator parser yielding array values . |
45,684 | private function release ( ) { \ assert ( $ this -> busy !== null ) ; $ deferred = $ this -> busy ; $ this -> busy = null ; $ deferred -> resolve ( ) ; } | Releases the transaction lock . |
45,685 | public function statementExecute ( string $ name , array $ params ) : Promise { \ assert ( isset ( $ this -> statements [ $ name ] ) , "Named statement not found when executing" ) ; $ storage = $ this -> statements [ $ name ] ; \ assert ( $ storage -> statement instanceof pq \ Statement , "Statement storage in invalid state" ) ; return new Coroutine ( $ this -> send ( [ $ storage -> statement , "execAsync" ] , $ params ) ) ; } | Executes the named statement using the given parameters . |
45,686 | public function unlisten ( ) : Promise { if ( ! $ this -> unlisten ) { throw new \ Error ( "Already unlistened on this channel" ) ; } $ promise = ( $ this -> unlisten ) ( $ this -> channel ) ; $ this -> unlisten = null ; return $ promise ; } | Unlistens from the channel . No more values will be emitted from this listener . |
45,687 | public function commit ( ) : Promise { if ( $ this -> handle === null ) { throw new TransactionError ( "The transaction has been committed or rolled back" ) ; } $ promise = $ this -> handle -> query ( "COMMIT" ) ; $ this -> handle = null ; $ promise -> onResolve ( $ this -> release ) ; return $ promise ; } | Commits the transaction and makes it inactive . |
45,688 | protected function createOptions ( $ options ) { if ( is_array ( $ options ) ) { return new Configuration \ Options ( $ options ) ; } if ( $ options instanceof LoopInterface ) { return new Configuration \ Options ( [ 'eventloop' => $ options ] ) ; } if ( $ options instanceof OptionsInterface ) { return $ options ; } throw new \ InvalidArgumentException ( 'Invalid type for client options' ) ; } | Creates an instance of Predis \ Async \ Configuration \ Options from different types of arguments or simply returns the passed argument if it is an instance of Predis \ Configuration \ OptionsInterface . |
45,689 | protected function createConnection ( $ parameters , OptionsInterface $ options ) { if ( $ parameters instanceof ConnectionInterface ) { if ( $ parameters -> getEventLoop ( ) !== $ this -> options -> eventloop ) { throw new ClientException ( 'Client and connection must share the same event loop.' ) ; } return $ parameters ; } $ eventloop = $ this -> options -> eventloop ; $ parameters = $ this -> createParameters ( $ parameters ) ; if ( $ options -> phpiredis ) { $ connection = new PhpiredisStreamConnection ( $ eventloop , $ parameters ) ; } else { $ connection = new StreamConnection ( $ eventloop , $ parameters ) ; } if ( isset ( $ options -> on_error ) ) { $ this -> setErrorCallback ( $ connection , $ options -> on_error ) ; } return $ connection ; } | Initializes a connection from various types of arguments or returns the passed object if it implements Predis \ Connection \ ConnectionInterface . |
45,690 | public function connect ( callable $ callback ) { $ this -> connection -> connect ( function ( $ connection ) use ( $ callback ) { call_user_func ( $ callback , $ this , $ connection ) ; } ) ; } | Opens the connection to the server . |
45,691 | public function monitor ( callable $ callback , $ autostart = true ) { $ monitor = new Monitor \ Consumer ( $ this , $ callback ) ; if ( $ autostart ) { $ monitor -> start ( ) ; } return $ monitor ; } | Creates a new monitor consumer . |
45,692 | public function setState ( $ state ) { $ state &= ~ 248 ; if ( ( $ state & ( $ state - 1 ) ) !== 0 ) { throw new InvalidArgumentException ( "State must be a valid state value" ) ; } $ this -> setFlags ( $ state ) ; $ this -> streamCallback = null ; } | Switches the internal state to one of the supported states . |
45,693 | public function setStreamingContext ( $ context , callable $ callback ) { if ( 0 === $ context &= ~ 7 ) { throw new InvalidArgumentException ( "Context must be a valid context value" ) ; } $ this -> setFlags ( $ context ) ; $ this -> streamCallback = $ callback ; } | Switches the internal state to one of the supported Redis contexts and associates a callback to process streaming reply items . |
45,694 | public function process ( $ response ) { if ( $ this -> checkFlags ( self :: CONNECTED ) ) { return call_user_func ( $ this -> processCallback , $ this , $ response ) ; } if ( $ this -> checkFlags ( self :: STREAM_CONTEXT ) ) { return call_user_func ( $ this -> streamCallback , $ this , $ response ) ; } throw new RuntimeException ( "Invalid connection state: $this" ) ; } | Processes a response depending on the current state . |
45,695 | protected function parsePayload ( $ response ) { if ( $ response instanceof ResponseInterface ) { return $ response ; } if ( $ this -> closing ) { return null ; } switch ( $ response [ 0 ] ) { case self :: SUBSCRIBE : case self :: UNSUBSCRIBE : case self :: PSUBSCRIBE : case self :: PUNSUBSCRIBE : if ( $ response [ 2 ] === 0 ) { $ this -> closing = true ; } return null ; case self :: MESSAGE : return ( object ) [ 'kind' => $ response [ 0 ] , 'channel' => $ response [ 1 ] , 'payload' => $ response [ 2 ] , ] ; case self :: PMESSAGE : return ( object ) [ 'kind' => $ response [ 0 ] , 'pattern' => $ response [ 1 ] , 'channel' => $ response [ 2 ] , 'payload' => $ response [ 3 ] , ] ; case self :: PONG : return ( object ) [ 'kind' => $ response [ 0 ] , 'payload' => $ response [ 1 ] , ] ; default : throw new RuntimeException ( "Received an unknown message type {$response[0]} inside of a pubsub context" ) ; } } | Parses the response array returned by the server into an object . |
45,696 | protected function writeRequest ( $ method , $ arguments , callable $ callback = null ) { $ arguments = Command :: normalizeArguments ( $ arguments ? : [ ] ) ; $ command = $ this -> client -> createCommand ( $ method , $ arguments ) ; $ this -> client -> executeCommand ( $ command , $ callback ) ; } | Writes a Redis command on the underlying connection . |
45,697 | protected function initializeReader ( ) { $ this -> reader = phpiredis_reader_create ( ) ; phpiredis_reader_set_status_handler ( $ this -> reader , $ this -> getStatusHandler ( ) ) ; phpiredis_reader_set_error_handler ( $ this -> reader , $ this -> getErrorHandler ( ) ) ; } | Initializes the protocol reader resource . |
45,698 | public static function create ( array $ tokens ) { HashMap :: assert ( $ tokens , 'tokens' ) ; if ( empty ( $ tokens [ 'ORDER' ] ) ) return [ ] ; $ headers = [ ] ; $ orderQueryArr = array_map ( function ( $ order ) { $ query = end ( $ order [ 'no_quotes' ] [ 'parts' ] ) ; if ( empty ( $ query ) ) return null ; return ! isset ( $ order [ 'direction' ] ) ? $ query : $ query . ' ' . $ order [ 'direction' ] ; } , $ tokens [ 'ORDER' ] ) ; array_push ( $ headers , 'Order: ' . implode ( ',' , $ orderQueryArr ) ) ; return $ headers ; } | Returns Order header |
45,699 | public function get ( $ alias ) { return ! empty ( $ this -> routingTable [ $ alias ] ) ? $ this -> routingTable [ $ alias ] : null ; } | returns the routing information about the entity alias |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.