idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
45,300 | public function resendVerificationEmail ( Request $ request ) { $ user = Auth :: user ( ) ; $ this -> validate ( $ request , [ 'email' => 'required|email|max:255|unique:users,email,' . $ user -> id ] ) ; $ user -> email = $ request -> email ; $ user -> save ( ) ; $ sent = resolve ( 'Lunaweb\EmailVerification\EmailVerification' ) -> sendVerifyLink ( $ user ) ; Session :: flash ( $ sent == EmailVerification :: VERIFY_LINK_SENT ? 'success' : 'error' , trans ( $ sent ) ) ; return redirect ( $ this -> redirectPath ( ) ) ; } | Resend the verification mail |
45,301 | protected function verifiedEmail ( $ user ) { $ this -> guard ( ) -> login ( $ user ) ; if ( ! $ user -> verified ) { $ user -> forceFill ( [ 'verified' => true ] ) -> save ( ) ; return true ; } return false ; } | Store the user s verification |
45,302 | protected function sendVerificationFailedResponse ( Request $ request , $ response ) { return redirect ( $ this -> redirectPath ( ) ) -> with ( 'error' , trans ( $ response ) ) ; } | Get the response for a failed user verification . |
45,303 | public function getAllFromCategories ( array $ categories ) { $ queryBuilder = $ this -> createQueryBuilder ( 'p' ) ; $ this -> addPerformanceJoinsToQueryBuilder ( $ queryBuilder ) ; return $ queryBuilder -> innerJoin ( 'p.categories' , 'c' ) -> where ( 'c.id IN (:categories)' ) -> setParameters ( [ 'categories' => $ categories , ] ) -> getQuery ( ) -> getResult ( ) ; } | Get all the the Purchasables from the received categories . |
45,304 | public function getHomePurchasables ( $ limit = 0 , $ useStock = true ) { $ queryBuilder = $ this -> createQueryBuilder ( 'p' ) ; $ this -> addPerformanceJoinsToQueryBuilder ( $ queryBuilder ) ; $ this -> addStockPropertiesToQueryBuilder ( $ queryBuilder , $ useStock ) ; $ query = $ queryBuilder -> andWhere ( 'p.enabled = :enabled' ) -> andWhere ( 'p.showInHome = :showInHome' ) -> setParameter ( 'enabled' , true ) -> setParameter ( 'showInHome' , true ) -> orderBy ( 'p.updatedAt' , 'DESC' ) ; if ( $ limit > 0 ) { $ query -> setMaxResults ( $ limit ) ; } return $ query -> getQuery ( ) -> getResult ( ) ; } | Get purchasables that can be shown in Home . |
45,305 | private function addStockPropertiesToQueryBuilder ( QueryBuilder $ queryBuilder , $ useStock ) { if ( $ useStock ) { $ queryBuilder -> andWhere ( $ queryBuilder -> expr ( ) -> orX ( $ queryBuilder -> expr ( ) -> gt ( 'p.stock' , ':stockZero' ) , $ queryBuilder -> expr ( ) -> eq ( 'p.stock' , ':infiniteStock' ) ) ) -> setParameter ( 'stockZero' , 0 ) -> setParameter ( 'infiniteStock' , ElcodiProductStock :: INFINITE_STOCK ) ; } } | Add stock properties to query builder . |
45,306 | private function addPerformanceJoinsToQueryBuilder ( QueryBuilder $ queryBuilder ) { $ queryBuilder -> select ( [ 'p' , 'pa' , 'pc' , 'rpc' , 'i' ] ) -> leftJoin ( 'p.principalImage' , 'pa' ) -> leftJoin ( 'p.priceCurrency' , 'pc' ) -> leftJoin ( 'p.reducedPriceCurrency' , 'rpc' ) -> leftJoin ( 'p.images' , 'i' ) -> groupBy ( 'p.id' ) ; } | Add performance joins . |
45,307 | public function dispatchOnPasswordRememberEvent ( AbstractUserInterface $ user , $ recoverUrl ) { $ event = new PasswordRememberEvent ( $ user , $ recoverUrl ) ; $ this -> eventDispatcher -> dispatch ( ElcodiUserEvents :: PASSWORD_REMEMBER , $ event ) ; } | Dispatch password remember event . |
45,308 | public function dispatchOnPasswordRecoverEvent ( AbstractUserInterface $ user ) { $ event = new PasswordRecoverEvent ( $ user ) ; $ this -> eventDispatcher -> dispatch ( ElcodiUserEvents :: PASSWORD_RECOVER , $ event ) ; } | Dispatch password recover event . |
45,309 | public function warmUp ( ) { $ translations = $ this -> entityTranslationRepository -> findAll ( ) ; foreach ( $ translations as $ translation ) { $ cacheKey = $ this -> buildKey ( $ translation -> getEntityType ( ) , $ translation -> getEntityId ( ) , $ translation -> getEntityField ( ) , $ translation -> getLocale ( ) ) ; $ this -> cache -> save ( $ cacheKey , $ translation -> getTranslation ( ) ) ; } return $ this ; } | Warm - up translations . |
45,310 | public function addMenuFilter ( MenuFilterInterface $ menuFilter , array $ menus , $ stage , $ priority ) { $ this -> addElement ( $ menuFilter , $ menus , $ stage , $ priority ) ; return $ this ; } | Add menu filter . |
45,311 | protected function processConfiguration ( ConfigurationInterface $ configuration , array $ configs ) { $ processor = new Processor ( ) ; return $ processor -> processConfiguration ( $ configuration , $ configs ) ; } | Process configuration . |
45,312 | public function dispatchCartCouponOnCheckEvent ( CartInterface $ cart , CouponInterface $ coupon ) { $ event = new CartCouponOnCheckEvent ( $ cart , $ coupon ) ; $ this -> eventDispatcher -> dispatch ( ElcodiCartCouponEvents :: CART_COUPON_ONCHECK , $ event ) ; } | Dispatch event to check a coupon applies to a Cart . |
45,313 | public function dispatchCartCouponOnApplyEvent ( CartInterface $ cart , CouponInterface $ coupon ) { $ event = new CartCouponOnApplyEvent ( $ cart , $ coupon ) ; $ this -> eventDispatcher -> dispatch ( ElcodiCartCouponEvents :: CART_COUPON_ONAPPLY , $ event ) ; } | Dispatch event just before a coupon is applied into a Cart . |
45,314 | public function dispatchCartCouponOnRemoveEvent ( CartCouponInterface $ cartCoupon ) { $ cart = $ cartCoupon -> getCart ( ) ; $ coupon = $ cartCoupon -> getCoupon ( ) ; $ event = new CartCouponOnRemoveEvent ( $ cart , $ coupon ) ; $ event -> setCartCoupon ( $ cartCoupon ) ; $ this -> eventDispatcher -> dispatch ( ElcodiCartCouponEvents :: CART_COUPON_ONREMOVE , $ event ) ; } | Dispatch event just before a coupon is removed from a Cart . |
45,315 | public function dispatchCartCouponOnRejectedEvent ( CartInterface $ cart , CouponInterface $ coupon ) { $ event = new CartCouponOnRejectedEvent ( $ cart , $ coupon ) ; $ this -> eventDispatcher -> dispatch ( ElcodiCartCouponEvents :: CART_COUPON_ONREJECTED , $ event ) ; } | Dispatch event when a coupon application is rejected . |
45,316 | public function create ( ) { $ classNamespace = $ this -> getEntityNamespace ( ) ; $ zone = new $ classNamespace ( ) ; $ zone -> setLocations ( [ ] ) -> setEnabled ( true ) -> setCreatedAt ( $ this -> now ( ) ) ; return $ zone ; } | Creates an Zone instance . |
45,317 | public function sendEmail ( PasswordRememberEvent $ event ) { $ this -> renderEmail ( 'Password remember email' , $ event -> getUser ( ) -> getEmail ( ) , [ 'user' => $ event -> getUser ( ) , 'rememberUrl' => $ event -> getRememberUrl ( ) , ] ) ; } | Send password remember email . |
45,318 | public function validateCartCouponRules ( CartCouponOnCheckEvent $ event ) { $ this -> cartCouponRuleValidator -> validateCartCouponRules ( $ event -> getCart ( ) , $ event -> getCoupon ( ) ) ; } | Check for the rules required by the coupon . |
45,319 | public function create ( ) { $ classNamespace = $ this -> getEntityNamespace ( ) ; $ manufacturer = new $ classNamespace ( ) ; $ manufacturer -> setImages ( new ArrayCollection ( ) ) -> setImagesSort ( '' ) -> setEnabled ( true ) -> setCreatedAt ( $ this -> now ( ) ) ; return $ manufacturer ; } | Creates an instance of Manufacturer . |
45,320 | public function getCommentTree ( $ source , $ context ) { $ key = $ this -> getSpecificSourceCacheKey ( $ source , $ context ) ; return isset ( $ this -> commentTree [ $ key ] ) ? $ this -> commentTree [ $ key ] : [ ] ; } | Get comment tree . |
45,321 | public function load ( $ source , $ context ) { $ key = $ this -> getSpecificSourceCacheKey ( $ source , $ context ) ; if ( isset ( $ this -> commentTree [ $ key ] ) && is_array ( $ this -> commentTree [ $ key ] ) ) { return $ this -> commentTree [ $ key ] ; } $ commentTree = $ this -> loadCommentTreeFromCache ( $ source , $ context ) ; if ( empty ( $ commentTree ) ) { $ commentTree = $ this -> buildCommentTreeAndSaveIntoCache ( $ source , $ context ) ; } $ this -> commentTree [ $ key ] = $ commentTree ; return $ commentTree ; } | Load Comment tree from cache . |
45,322 | public function invalidateCache ( $ source , $ context ) { $ key = $ this -> getSpecificSourceCacheKey ( $ source , $ context ) ; $ this -> cache -> delete ( $ this -> getSpecificSourceCacheKey ( $ source , $ context ) ) ; unset ( $ this -> commentTree [ $ key ] ) ; return $ this ; } | Invalidates cache from source . |
45,323 | public function reload ( $ source , $ context ) { $ this -> invalidateCache ( $ source , $ context ) ; return $ this -> load ( $ source , $ context ) ; } | Invalidates cache and reload all cache from source . |
45,324 | public function createCommentStructure ( CommentInterface $ comment , VotePackage $ commentVotePackage = null ) { $ commentStructure = [ 'id' => $ comment -> getId ( ) , 'authorName' => $ comment -> getAuthorName ( ) , 'authorEmail' => $ comment -> getAuthorEmail ( ) , 'content' => $ comment -> getContent ( ) , 'context' => $ comment -> getContext ( ) , 'createdAt' => $ comment -> getCreatedAt ( ) -> format ( 'Y-m-d H:i:s' ) , 'updatedAt' => $ comment -> getUpdatedAt ( ) -> format ( 'Y-m-d H:i:s' ) , ] ; if ( $ commentVotePackage instanceof VotePackage ) { $ commentStructure = array_merge ( $ commentStructure , [ 'nbVotes' => $ commentVotePackage -> getNbVotes ( ) , 'nbUpVotes' => $ commentVotePackage -> getNbUpVotes ( ) , 'nbDownVotes' => $ commentVotePackage -> getNbDownVotes ( ) , ] ) ; } return $ commentStructure ; } | Create structure for comment . |
45,325 | private function loadCommentTreeFromCache ( $ source , $ context ) { return $ this -> encoder -> decode ( $ this -> cache -> fetch ( $ this -> getSpecificSourceCacheKey ( $ source , $ context ) ) ) ; } | Load comment tree from cache . |
45,326 | private function buildCommentTreeAndSaveIntoCache ( $ source , $ context ) { $ commentTree = $ this -> buildCommentTree ( $ source , $ context ) ; $ this -> saveCommentTreeIntoCache ( $ commentTree , $ source , $ context ) ; return $ commentTree ; } | Build comment tree and save it into cache . |
45,327 | private function buildCommentTree ( $ source , $ context ) { $ comments = $ this -> commentRepository -> getAllCommentsSortedByParentAndIdAsc ( $ source , $ context ) ; $ commentTree = [ 0 => null , 'children' => [ ] , ] ; foreach ( $ comments as $ comment ) { $ parentCommentId = 0 ; $ commentId = $ comment -> getId ( ) ; if ( $ comment -> getParent ( ) instanceof CommentInterface ) { $ parentCommentId = $ comment -> getParent ( ) -> getId ( ) ; } if ( $ parentCommentId && ! isset ( $ commentTree [ $ parentCommentId ] ) ) { $ commentTree [ $ parentCommentId ] = [ 'entity' => null , 'children' => [ ] , ] ; } if ( ! isset ( $ commentTree [ $ commentId ] ) ) { $ commentTree [ $ commentId ] = [ 'entity' => null , 'children' => [ ] , ] ; } $ commentVotePackage = $ this -> voteManager -> getCommentVotes ( $ comment ) ; $ commentTree [ $ commentId ] [ 'entity' ] = $ this -> createCommentStructure ( $ comment , $ commentVotePackage ) ; $ commentTree [ $ parentCommentId ] [ 'children' ] [ ] = & $ commentTree [ $ commentId ] ; } return $ commentTree [ 0 ] [ 'children' ] ? : [ ] ; } | Build comments tree from doctrine given their source . |
45,328 | private function saveCommentTreeIntoCache ( array $ commentTree , $ source , $ context ) { $ this -> cache -> save ( $ this -> getSpecificSourceCacheKey ( $ source , $ context ) , $ this -> encoder -> encode ( $ commentTree ) ) ; return $ this ; } | Save given comment tree into cache . |
45,329 | private function getSpecificSourceCacheKey ( $ source , $ context ) { $ source = str_replace ( '.' , '_' , $ source ) ; $ context = str_replace ( '.' , '_' , $ context ) ; return $ this -> key . '.' . $ source . '.' . $ context ; } | Get cache key given the source . |
45,330 | public function renderByIdAction ( $ id , $ path = '' ) { $ page = $ this -> pageRepository -> findOneById ( $ id ) ; return $ this -> pageResponseTransformer -> createResponseFromPage ( $ page , $ path ) ; } | Renders a page given its id and path . |
45,331 | public function renderByPathAction ( $ path = '' ) { $ page = $ this -> pageRepository -> findOneByPath ( $ path ) ; return $ this -> pageResponseTransformer -> createResponseFromPage ( $ page , $ path ) ; } | Renders a page given its path . |
45,332 | public function setGender ( $ gender ) { if ( ! in_array ( $ gender , self :: $ genders , true ) ) { return $ this ; } $ this -> gender = $ gender ; return $ this ; } | Set gender if the gender is allowed . |
45,333 | public function resize ( $ imageData , $ height , $ width , $ type = ElcodiMediaImageResizeTypes :: FORCE_MEASURES ) { $ originalResource = imagecreatefromstring ( $ imageData ) ; $ originalWidth = imagesx ( $ originalResource ) ; $ originalHeight = imagesy ( $ originalResource ) ; $ dimensions = Dimensions :: create ( $ originalWidth , $ originalHeight , $ width , $ height , $ type ) ; $ newResource = imagecreatetruecolor ( $ dimensions -> getDstFrameX ( ) , $ dimensions -> getDstFrameY ( ) ) ; $ backgroundColor = imagecolorallocate ( $ newResource , 255 , 255 , 255 ) ; imagefill ( $ newResource , 0 , 0 , $ backgroundColor ) ; imagecopyresampled ( $ newResource , $ originalResource , $ dimensions -> getDstX ( ) , $ dimensions -> getDstY ( ) , $ dimensions -> getSrcX ( ) , $ dimensions -> getSrcY ( ) , $ dimensions -> getDstWidth ( ) , $ dimensions -> getDstHeight ( ) , $ dimensions -> getSrcWidth ( ) , $ dimensions -> getSrcHeight ( ) ) ; ob_start ( ) ; imagejpeg ( $ newResource ) ; $ content = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ content ; } | Interface for resize implementations . |
45,334 | public function vote ( CommentInterface $ comment , $ authorToken , $ type ) { $ vote = $ this -> commentVoteObjectDirector -> findOneBy ( [ 'authorToken' => $ authorToken , 'comment' => $ comment , ] ) ; $ edited = true ; if ( ! ( $ vote instanceof VoteInterface ) ) { $ vote = $ this -> commentVoteObjectDirector -> create ( ) -> setAuthorToken ( $ authorToken ) -> setComment ( $ comment ) ; $ edited = false ; } $ vote -> setType ( $ type ) ; $ this -> commentVoteObjectDirector -> save ( $ vote ) ; $ this -> commentEventDispatcher -> dispatchCommentOnVotedEvent ( $ comment , $ vote , $ edited ) ; return $ vote ; } | Vote action . |
45,335 | public function removeVote ( CommentInterface $ comment , $ authorToken ) { $ vote = $ this -> commentVoteObjectDirector -> findOneBy ( [ 'authorToken' => $ authorToken , 'comment' => $ comment , ] ) ; if ( $ vote instanceof VoteInterface ) { $ this -> commentVoteObjectDirector -> remove ( $ vote ) ; } return $ this ; } | Remove Vote action . |
45,336 | public function getCommentVotes ( CommentInterface $ comment ) { $ votes = $ this -> commentVoteObjectDirector -> findBy ( [ 'comment' => $ comment , ] ) ; return VotePackage :: create ( $ votes ) ; } | Get comment votes . |
45,337 | public function create ( ) { $ classNamespace = $ this -> getEntityNamespace ( ) ; $ cart = new $ classNamespace ( ) ; $ cart -> setOrdered ( false ) -> setCartLines ( new ArrayCollection ( ) ) -> setPurchasableAmount ( $ this -> createZeroAmountMoney ( ) ) -> setAmount ( $ this -> createZeroAmountMoney ( ) ) -> setCouponAmount ( $ this -> createZeroAmountMoney ( ) ) -> setShippingAmount ( $ this -> createZeroAmountMoney ( ) ) -> setCreatedAt ( $ this -> now ( ) ) ; return $ cart ; } | Creates an instance of Cart . |
45,338 | public function getOrdersToPrepare ( ) { $ res = $ this -> createQueryBuilder ( 'o' ) -> innerJoin ( 'o.shippingLastStateLine' , 'sl' ) -> where ( 'sl.name = \'preparing\'' ) -> orderBy ( 'o.updatedAt' , 'ASC' ) -> getQuery ( ) -> getResult ( ) ; return $ res ; } | Gets the orders to prepare . |
45,339 | public function fixCategoriesIntegrityByArray ( array $ categorizables ) { foreach ( $ categorizables as $ categorizable ) { if ( $ categorizable instanceof CategorizableInterface ) { $ this -> fixCategoriesIntegrity ( $ categorizable ) ; } } } | Fixes all purchasable categories given a set of purchasables . |
45,340 | public function fixCategoriesIntegrity ( CategorizableInterface $ categorizable ) { $ principalCategory = $ categorizable -> getPrincipalCategory ( ) ; $ categories = $ categorizable -> getCategories ( ) ; if ( $ principalCategory instanceof CategoryInterface ) { $ categorizable -> addCategory ( $ principalCategory ) ; } elseif ( ! $ categories -> isEmpty ( ) ) { $ categorizable -> setPrincipalCategory ( $ categories -> first ( ) ) ; } } | Fixes the categories of a categorizable object . |
45,341 | public function preFlush ( PreFlushEventArgs $ args ) { $ entityManager = $ args -> getEntityManager ( ) ; $ scheduledInsertions = $ entityManager -> getUnitOfWork ( ) -> getScheduledEntityInsertions ( ) ; $ this -> categoryIntegrityFixer -> fixCategoriesIntegrityByArray ( $ scheduledInsertions ) ; } | Before the flush we check that the product categories are right . |
45,342 | public function preUpdate ( PreUpdateEventArgs $ event ) { $ entity = $ event -> getEntity ( ) ; if ( $ entity instanceof CategorizableInterface ) { $ this -> categoryIntegrityFixer -> fixCategoriesIntegrity ( $ entity ) ; } } | Before an update we check that the product categories are right . |
45,343 | private function createResponseObject ( callable $ callable ) { try { $ response = new JsonResponse ( $ callable ( ) ) ; } catch ( EntityNotFoundException $ notFoundException ) { $ response = new JsonResponse ( $ notFoundException -> getMessage ( ) , 404 ) ; } catch ( Exception $ e ) { $ response = new JsonResponse ( 'API exception. Please contact your webmaster' , 500 ) ; } return $ response ; } | Create new response . |
45,344 | private function normalizeLocationDataArray ( array $ locationDataArray ) { $ normalizedLocationDataArray = [ ] ; foreach ( $ locationDataArray as $ locationData ) { $ normalizedLocationDataArray [ ] = $ this -> normalizeLocationData ( $ locationData ) ; } return $ normalizedLocationDataArray ; } | Normalize an array of LocationData objects to be json encoded . |
45,345 | private function normalizeLocationData ( LocationData $ locationData ) { return [ 'id' => $ locationData -> getId ( ) , 'name' => $ locationData -> getName ( ) , 'code' => $ locationData -> getCode ( ) , 'type' => $ locationData -> getType ( ) , ] ; } | Normalize LocationData object to be json encoded . |
45,346 | public function updateStockByLoadedStockUpdaters ( PurchasableInterface $ purchasable , $ stockToDecrease ) { foreach ( $ this -> stockUpdaters as $ stockUpdater ) { $ stockUpdateNamespace = $ stockUpdater -> getPurchasableNamespace ( ) ; if ( $ purchasable instanceof $ stockUpdateNamespace ) { return $ stockUpdater -> updateStock ( $ purchasable , $ stockToDecrease ) ; } } return false ; } | Update stock for a Purchasable instance given a collection of stock updaters loaded . |
45,347 | public function loadEntriesFromLastDays ( $ days ) { $ entries = $ this -> entryRepository -> getEntriesFromLastDays ( $ days ) ; foreach ( $ entries as $ entry ) { $ this -> metricsBucket -> add ( $ entry ) ; } return $ entries ; } | Load metrics from last X days and cache them . |
45,348 | public function resize ( $ imageData , $ height , $ width , $ type = ElcodiMediaImageResizeTypes :: FORCE_MEASURES ) { if ( ElcodiMediaImageResizeTypes :: NO_RESIZE === $ type ) { return $ imageData ; } $ originalFile = new File ( tempnam ( sys_get_temp_dir ( ) , '_original' ) ) ; $ resizedFile = new File ( tempnam ( sys_get_temp_dir ( ) , '_resize' ) ) ; file_put_contents ( $ originalFile , $ imageData ) ; $ pb = new ProcessBuilder ( ) ; $ pb -> add ( $ this -> imageConverterBin ) -> add ( $ originalFile -> getPathname ( ) ) -> add ( '-profile' ) -> add ( $ this -> profile ) ; $ pb -> add ( '-filter' ) -> add ( 'Lanczos' ) ; if ( $ width == 0 ) { $ width = '' ; } if ( $ height == 0 ) { $ height = '' ; } if ( $ width || $ height ) { $ pb -> add ( '-resize' ) ; switch ( $ type ) { case ElcodiMediaImageResizeTypes :: INSET : $ pb -> add ( $ width . 'x' . $ height ) ; break ; case ElcodiMediaImageResizeTypes :: INSET_FILL_WHITE : $ pb -> add ( $ width . 'x' . $ height ) -> add ( '-gravity' ) -> add ( 'center' ) -> add ( '-extent' ) -> add ( $ width . 'x' . $ height ) ; break ; case ElcodiMediaImageResizeTypes :: OUTBOUNDS_FILL_WHITE : $ pb -> add ( $ width . 'x' . $ height . '' ) ; break ; case ElcodiMediaImageResizeTypes :: OUTBOUND_CROP : $ pb -> add ( $ width . 'x' . $ height . '^' ) -> add ( '-gravity' ) -> add ( 'center' ) -> add ( '-crop' ) -> add ( $ width . 'x' . $ height . '+0+0' ) ; break ; case ElcodiMediaImageResizeTypes :: FORCE_MEASURES : default : $ pb -> add ( $ width . 'x' . $ height . '!' ) ; break ; } } $ proc = $ pb -> add ( $ resizedFile -> getPathname ( ) ) -> getProcess ( ) ; $ proc -> run ( ) ; if ( false !== strpos ( $ proc -> getOutput ( ) , 'ERROR' ) ) { throw new \ RuntimeException ( $ proc -> getOutput ( ) ) ; } $ imageContent = file_get_contents ( $ resizedFile -> getRealPath ( ) ) ; unlink ( $ originalFile ) ; unlink ( $ resizedFile ) ; return $ imageContent ; } | Generate Thumbnail images with ImageMagick . |
45,349 | protected function generateEntryKey ( $ token , $ event , $ date ) { return $ this -> normalizeForKey ( $ token ) . '.' . $ this -> normalizeForKey ( $ event ) . '.' . $ this -> normalizeForKey ( $ date ) ; } | Create key given an entry . |
45,350 | public function getLocale ( ) { $ locale = $ this -> requestStack -> getCurrentRequest ( ) instanceof Request ? $ this -> requestStack -> getCurrentRequest ( ) -> getLocale ( ) : $ this -> defaultLocale ; return Locale :: create ( $ locale ) ; } | Get usable locale from current request environment . |
45,351 | public function compile ( ) { $ translator = $ this -> checkNamespace ( $ this -> configuration ) -> checkAlias ( $ this -> configuration ) -> checkMethods ( $ this -> configuration ) -> createTranslator ( ) ; return $ translator ; } | Compile translator . |
45,352 | public function checkNamespace ( array $ configuration ) { foreach ( $ configuration as $ classNamespace => $ classConfiguration ) { if ( class_exists ( $ classNamespace ) || interface_exists ( $ classNamespace ) ) { return $ this ; } } throw new TranslationDefinitionException ( ) ; } | Check namespace . |
45,353 | public function checkAlias ( array $ configuration ) { foreach ( $ configuration as $ classNamespace => $ classConfiguration ) { if ( isset ( $ classConfiguration [ 'alias' ] ) && $ classConfiguration [ 'alias' ] ) { return $ this ; } } throw new TranslationDefinitionException ( ) ; } | Check alias . |
45,354 | public function checkMethods ( array $ configuration ) { foreach ( $ configuration as $ classNamespace => $ classConfiguration ) { if ( ! isset ( $ classConfiguration [ 'idGetter' ] ) || ! method_exists ( $ classNamespace , $ classConfiguration [ 'idGetter' ] ) || ! isset ( $ classConfiguration [ 'fields' ] ) || ! is_array ( $ classConfiguration [ 'fields' ] ) ) { throw new TranslationDefinitionException ( ) ; } foreach ( $ classConfiguration [ 'fields' ] as $ fieldName => $ fieldConfiguration ) { if ( $ fieldName && $ fieldConfiguration && is_array ( $ fieldConfiguration ) && isset ( $ fieldConfiguration [ 'getter' ] ) && method_exists ( $ classNamespace , $ fieldConfiguration [ 'getter' ] ) && isset ( $ fieldConfiguration [ 'setter' ] ) && method_exists ( $ classNamespace , $ fieldConfiguration [ 'setter' ] ) ) { continue ; } throw new TranslationDefinitionException ( 'Field ' . $ classNamespace . ' not found, or methods [' . $ fieldConfiguration [ 'getter' ] . ', ' . $ fieldConfiguration [ 'setter' ] . '] not found inside the class' ) ; } } return $ this ; } | Check namespaces . |
45,355 | public function createTranslator ( ) { return $ this -> entityTranslatorFactory -> create ( $ this -> entityTranslationProvider , $ this -> configuration , $ this -> fallback ) ; } | Compile the translator and return an instance . |
45,356 | public function initialize ( $ object , StateLineStack $ stateLineStack , $ description ) { if ( $ stateLineStack -> getLastStateLine ( ) instanceof StateLineInterface ) { throw new ObjectAlreadyInitializedException ( ) ; } $ pointOfEntry = $ this -> machine -> getPointOfEntry ( ) ; $ stateLine = $ this -> createStateLine ( $ pointOfEntry , $ description ) ; $ stateLineStack -> addStateLine ( $ stateLine ) ; $ this -> machineEventDispatcher -> dispatchInitializationEvents ( $ this -> machine , $ object , $ stateLineStack ) ; return $ stateLineStack ; } | Initialize the object into the machine . |
45,357 | public function createStateLine ( $ name , $ description ) { $ stateLine = $ this -> stateLineFactory -> create ( ) -> setName ( $ name ) -> setDescription ( $ description ) ; return $ stateLine ; } | Create an state line given its name and description . |
45,358 | private function applyTransitionAction ( $ object , StateLineStack $ stateLineStack , $ transitionName , $ description , $ transitionAction ) { $ startState = $ stateLineStack -> getLastStateLine ( ) ; if ( ! ( $ startState instanceof StateLineInterface ) ) { throw new ObjectNotInitializedException ( ) ; } $ transition = $ this -> machine -> $ transitionAction ( $ startState -> getName ( ) , $ transitionName ) ; $ stateLine = $ this -> createStateLine ( $ transition -> getFinal ( ) -> getName ( ) , $ description ) ; $ stateLineStack -> addStateLine ( $ stateLine ) ; $ this -> machineEventDispatcher -> dispatchTransitionEvents ( $ this -> machine , $ object , $ stateLineStack , $ transition ) ; return $ stateLineStack ; } | Applies a transition action given a object and the kind of transition is needed . |
45,359 | private function getCustomerCart ( CustomerInterface $ customer ) { $ customerCart = $ customer -> getCarts ( ) -> filter ( function ( CartInterface $ cart ) { return ! $ cart -> isOrdered ( ) ; } ) -> first ( ) ; if ( $ customerCart instanceof CartInterface ) { return $ customerCart ; } return null ; } | Return customer related cart . |
45,360 | private function resolveCarts ( CustomerInterface $ customer , CartInterface $ cartFromCustomer = null , CartInterface $ cartFromSession = null ) { if ( $ cartFromCustomer ) { return $ cartFromCustomer ; } else { if ( ! $ cartFromSession ) { $ cart = $ this -> cartFactory -> create ( ) ; } else { $ cart = $ cartFromSession ; if ( $ customer -> getId ( ) ) { $ cart -> setCustomer ( $ customer ) ; $ customer -> addCart ( $ cart ) ; } } return $ cart ; } } | Resolves a cart given a customer cart and a session cart . |
45,361 | public function addCartLine ( CartLineInterface $ cartLine ) { if ( ! $ this -> cartLines -> contains ( $ cartLine ) ) { $ this -> cartLines -> add ( $ cartLine ) ; } return $ this ; } | Add Cart Line . |
45,362 | public function getTotalItemNumber ( ) { return array_reduce ( $ this -> cartLines -> toArray ( ) , function ( $ previousTotal , CartLineInterface $ current ) { return $ previousTotal + $ current -> getQuantity ( ) ; } , 0 ) ; } | Return the total amount of items added to the Cart . |
45,363 | public function getDepth ( ) { return array_reduce ( $ this -> cartLines -> toArray ( ) , function ( $ depth , CartLineInterface $ cartLine ) { return max ( $ depth , $ cartLine -> getDepth ( ) ) ; } , 0 ) ; } | Return the maximum depth of all the cartLines . |
45,364 | public function getHeight ( ) { return array_reduce ( $ this -> cartLines -> toArray ( ) , function ( $ height , CartLineInterface $ cartLine ) { return max ( $ height , $ cartLine -> getHeight ( ) ) ; } , 0 ) ; } | Return the maximum height of all the cartLines . |
45,365 | public function getWidth ( ) { return array_reduce ( $ this -> cartLines -> toArray ( ) , function ( $ width , CartLineInterface $ cartLine ) { return max ( $ width , $ cartLine -> getWidth ( ) ) ; } , 0 ) ; } | Return the maximum width of all the cartLines . |
45,366 | public function getWeight ( ) { return array_reduce ( $ this -> cartLines -> toArray ( ) , function ( $ weight , CartLineInterface $ cartLine ) { return $ weight + $ cartLine -> getWeight ( ) ; } , 0 ) ; } | Get the sum of all CartLines weight . |
45,367 | public function create ( $ locationId , $ locationName , $ locationCode , $ locationType ) { return new LocationData ( $ locationId , $ locationName , $ locationCode , $ locationType ) ; } | Create new Location . |
45,368 | public function buildCategoryTree ( ) { $ categories = $ this -> categoryRepository -> getAllCategoriesSortedByParentAndPositionAsc ( ) ; $ categoryTree = [ 0 => null , 'children' => [ ] , ] ; foreach ( $ categories as $ category ) { $ parentCategoryId = 0 ; $ categoryId = $ category -> getId ( ) ; if ( ! $ category -> isRoot ( ) ) { if ( $ category -> getParent ( ) instanceof CategoryInterface ) { $ parentCategoryId = $ category -> getParent ( ) -> getId ( ) ; } else { continue ; } } if ( $ parentCategoryId && ! isset ( $ categoryTree [ $ parentCategoryId ] ) ) { $ categoryTree [ $ parentCategoryId ] = [ 'entity' => null , 'children' => [ ] , ] ; } if ( ! isset ( $ categoryTree [ $ categoryId ] ) ) { $ categoryTree [ $ categoryId ] = [ 'entity' => null , 'children' => [ ] , ] ; } $ categoryTree [ $ categoryId ] [ 'entity' ] = $ category ; $ categoryTree [ $ parentCategoryId ] [ 'children' ] [ ] = & $ categoryTree [ $ categoryId ] ; } return $ categoryTree [ 0 ] [ 'children' ] ? : [ ] ; } | Builds a category tree with all the categories and subcategories . |
45,369 | public function canBeApplied ( CartInterface $ cart , CouponInterface $ coupon ) { return $ coupon -> getType ( ) === self :: id ( ) && 1 === preg_match ( $ this -> regexp ( ) , $ coupon -> getValue ( ) ) ; } | Can be applied . |
45,370 | protected function evaluatePurchasableType ( PurchasableInterface $ purchasable , $ modifiers ) { if ( empty ( $ modifiers ) ) { return true ; } if ( false === strpos ( $ modifiers , 'P' ) && false === strpos ( $ modifiers , 'V' ) && false === strpos ( $ modifiers , 'K' ) ) { return true ; } if ( $ purchasable instanceof ProductInterface && false !== strpos ( $ modifiers , 'P' ) ) { return true ; } if ( $ purchasable instanceof VariantInterface && false !== strpos ( $ modifiers , 'V' ) ) { return true ; } if ( $ purchasable instanceof PackInterface && false !== strpos ( $ modifiers , 'K' ) ) { return true ; } return false ; } | Evaluate purchasables . |
45,371 | public function populate ( $ countryCode ) { $ countryCode = strtoupper ( $ countryCode ) ; $ downloadedFilePath = $ this -> downloadFile ( $ countryCode ) ; $ extractedPath = $ this -> extractFile ( $ downloadedFilePath ) ; $ rootLocation = $ this -> loadLocationsFrom ( $ countryCode , $ extractedPath ) ; return $ rootLocation ; } | Populate a country . |
45,372 | private function downloadFile ( $ countryCode ) { $ tempname = sys_get_temp_dir ( ) . '/elcodi-locator-geonames-' . $ countryCode . '.zip' ; if ( ! file_exists ( $ tempname ) ) { $ dirname = dirname ( $ tempname ) ; if ( ! file_exists ( $ dirname ) ) { mkdir ( $ dirname , 0777 , true ) ; } $ downloadUrl = 'http://download.geonames.org/export/zip/' . $ countryCode . '.zip' ; copy ( $ downloadUrl , $ tempname ) ; } return $ tempname ; } | Download data file from country Avoids download if the file exists . |
45,373 | private function extractFile ( $ tempname ) { $ extractedFiles = $ this -> extractor -> extractFromFile ( $ tempname ) -> files ( ) -> notName ( 'readme.txt' ) -> getIterator ( ) ; $ extractedFiles -> rewind ( ) ; if ( ! $ extractedFiles -> valid ( ) ) { throw new FileNotFoundException ( ) ; } return $ extractedFiles -> current ( ) ; } | Download file and return new pathname of extracted content . |
45,374 | private function loadLocationsFrom ( $ countryCode , $ pathname ) { $ countryInfo = $ this -> getCountryInfo ( $ countryCode ) ; $ country = $ this -> locationBuilder -> addLocation ( $ countryInfo [ 0 ] , $ countryInfo [ 1 ] , $ countryInfo [ 0 ] , 'country' ) ; $ interpreter = new Interpreter ( ) ; $ interpreter -> unstrict ( ) ; $ nbItems = 0 ; $ interpreter -> addObserver ( function ( array $ columns ) use ( $ country , & $ nbItems ) { if ( isset ( $ columns [ 1 ] , $ columns [ 2 ] , $ columns [ 3 ] , $ columns [ 4 ] , $ columns [ 5 ] , $ columns [ 6 ] ) ) { ++ $ nbItems ; $ stateId = $ this -> normalizeId ( $ columns [ 4 ] ) ; $ state = $ this -> locationBuilder -> addLocation ( $ country -> getId ( ) . '_' . $ stateId , $ columns [ 3 ] , $ stateId , 'state' , $ country ) ; $ provinceId = $ this -> normalizeId ( $ columns [ 6 ] ) ; $ province = $ this -> locationBuilder -> addLocation ( $ state -> getId ( ) . '_' . $ provinceId , $ columns [ 5 ] , $ provinceId , 'province' , $ state ) ; $ cityId = $ this -> normalizeId ( $ columns [ 2 ] ) ; $ city = $ this -> locationBuilder -> addLocation ( $ province -> getId ( ) . '_' . $ cityId , $ columns [ 2 ] , $ cityId , 'city' , $ province ) ; $ postalCodeId = $ this -> normalizeId ( $ columns [ 1 ] ) ; $ this -> locationBuilder -> addLocation ( $ city -> getId ( ) . '_' . $ postalCodeId , $ columns [ 1 ] , $ postalCodeId , 'postalcode' , $ city ) ; } } ) ; $ config = new LexerConfig ( ) ; $ config -> setDelimiter ( "\t" ) ; $ lexer = new Lexer ( $ config ) ; $ lexer -> parse ( $ pathname , $ interpreter ) ; return $ country ; } | Extract data from de CSV and create new Location objects . |
45,375 | public function findOneByEmail ( $ email ) { $ user = $ this -> findOneBy ( [ 'email' => $ email , ] ) ; return ( $ user instanceof AbstractUserInterface ) ? $ user : null ; } | Find one Entity given an email . |
45,376 | public function uploadFile ( FileInterface $ file , $ data , $ overwrite = true ) { $ this -> filesystem -> write ( $ this -> fileIdentifierTransformer -> transform ( $ file ) , $ data , $ overwrite ) ; return $ this ; } | Adds a File to an specific FileSystem given an specific data . |
45,377 | public function downloadFile ( FileInterface $ file ) { $ content = $ this -> filesystem -> read ( $ this -> fileIdentifierTransformer -> transform ( $ file ) ) ; $ file -> setContent ( $ content ) ; return $ file ; } | Given a Doctrine mapped File instance retrieves its data and fill content local variable with it . |
45,378 | public function refreshCouponAmount ( CartInterface $ cart ) { $ couponAmount = Money :: create ( 0 , $ this -> currencyWrapper -> get ( ) ) ; $ coupons = $ this -> cartCouponManager -> getCoupons ( $ cart ) ; foreach ( $ coupons as $ coupon ) { $ currentCouponAmount = $ this -> cartCouponApplicatorCollector -> getCouponAbsoluteValue ( $ cart , $ coupon ) ; $ coupon -> setAbsolutePrice ( $ currentCouponAmount ) ; $ couponAmount = $ couponAmount -> add ( $ currentCouponAmount ) ; } $ cart -> setCouponAmount ( $ couponAmount ) ; } | Calculates coupons price given actual Cart . |
45,379 | public function add ( MoneyInterface $ other ) { $ wrappedMoney = $ this -> wrappedMoney -> add ( $ this -> newWrappedMoneyFromMoney ( $ other ) ) ; return self :: create ( $ wrappedMoney -> getAmount ( ) , $ other -> getCurrency ( ) ) ; } | Adds a Money and returns the result as a new Money . |
45,380 | public function multiply ( $ factor ) { $ wrappedMoney = $ this -> wrappedMoney -> multiply ( $ factor ) ; return self :: create ( $ wrappedMoney -> getAmount ( ) , $ this -> getCurrency ( ) ) ; } | Multiplies current Money amount by a factor returns the result as a new Money . |
45,381 | private function newWrappedMoneyFromMoney ( MoneyInterface $ money ) { return new WrappedMoney ( $ money -> getAmount ( ) , new WrappedCurrency ( $ money -> getCurrency ( ) -> getIso ( ) ) ) ; } | Returns a new WrappedMoney given a MoneyInterface . |
45,382 | public function translate ( $ object , $ locale ) { $ classStack = $ this -> getNamespacesFromClass ( get_class ( $ object ) ) ; foreach ( $ classStack as $ classNamespace ) { if ( ! array_key_exists ( $ classNamespace , $ this -> configuration ) ) { continue ; } $ configuration = $ this -> configuration [ $ classNamespace ] ; $ idGetter = $ configuration [ 'idGetter' ] ; $ entityId = $ object -> $ idGetter ( ) ; foreach ( $ configuration [ 'fields' ] as $ fieldName => $ fieldConfiguration ) { $ setter = $ fieldConfiguration [ 'setter' ] ; $ translation = $ this -> entityTranslationProvider -> getTranslation ( $ configuration [ 'alias' ] , $ entityId , $ fieldName , $ locale ) ; if ( $ translation || ! $ this -> fallback ) { $ object -> $ setter ( $ translation ) ; } } } return $ object ; } | Translate object . |
45,383 | public function save ( $ object , array $ translations ) { $ classStack = $ this -> getNamespacesFromClass ( get_class ( $ object ) ) ; foreach ( $ classStack as $ classNamespace ) { if ( ! array_key_exists ( $ classNamespace , $ this -> configuration ) ) { continue ; } $ configuration = $ this -> configuration [ $ classNamespace ] ; $ idGetter = $ configuration [ 'idGetter' ] ; $ entityId = $ object -> $ idGetter ( ) ; foreach ( $ translations as $ locale => $ translation ) { foreach ( $ configuration [ 'fields' ] as $ fieldName => $ fieldConfiguration ) { if ( isset ( $ translation [ $ fieldName ] ) ) { $ this -> entityTranslationProvider -> setTranslation ( $ configuration [ 'alias' ] , $ entityId , $ fieldName , $ translation [ $ fieldName ] , $ locale ) ; } } } } $ this -> entityTranslationProvider -> flushTranslations ( ) ; return $ this ; } | Saves object translations . |
45,384 | protected function getNamespacesFromClass ( $ namespace ) { $ classStack = [ $ namespace ] ; $ classStack = array_merge ( $ classStack , class_parents ( $ namespace ) ) ; $ classStack = array_merge ( $ classStack , class_implements ( $ namespace ) ) ; return $ classStack ; } | Get all possible classes given an object . |
45,385 | public function addElement ( $ element , $ menus , $ stage , $ priority = 0 ) { $ priority = ( int ) $ priority ; $ elementId = spl_object_hash ( $ element ) ; $ menus = is_array ( $ menus ) ? $ menus : [ $ menus ] ; if ( empty ( $ menus ) ) { $ this -> allElements [ $ elementId ] = $ element ; } else { foreach ( $ menus as $ menu ) { $ this -> addElementByMenuCode ( $ element , $ menu ) ; } } $ this -> addElementByStage ( $ element , $ stage ) ; $ this -> priorities [ $ elementId ] = $ priority ; return $ this ; } | Add element . |
45,386 | public function getElementsByMenuCodeAndStage ( $ menuCode , $ stage ) { $ elementsByMenuCode = isset ( $ this -> elementsStoredByMenuCode [ $ menuCode ] ) ? $ this -> elementsStoredByMenuCode [ $ menuCode ] : [ ] ; $ elementsByStage = isset ( $ this -> elementsStoredByStage [ $ stage ] ) ? $ this -> elementsStoredByStage [ $ stage ] : [ ] ; $ elements = array_values ( array_intersect_key ( array_merge ( $ this -> allElements , $ elementsByMenuCode ) , $ elementsByStage ) ) ; usort ( $ elements , function ( $ element1 , $ element2 ) { $ element1Id = spl_object_hash ( $ element1 ) ; $ element2Id = spl_object_hash ( $ element2 ) ; return $ this -> priorities [ $ element1Id ] <= $ this -> priorities [ $ element2Id ] ; } ) ; return $ elements ; } | Get elements given a stage and the code of the menu . |
45,387 | private function addElementByMenuCode ( $ element , $ menuCode ) { if ( ! isset ( $ this -> elementsStoredByMenuCode [ $ menuCode ] ) ) { $ this -> elementsStoredByMenuCode [ $ menuCode ] = [ ] ; } $ elementId = spl_object_hash ( $ element ) ; $ this -> elementsStoredByMenuCode [ $ menuCode ] [ $ elementId ] = $ element ; return $ this ; } | Add element by menu code . |
45,388 | private function addElementByStage ( $ element , $ stage ) { if ( ! isset ( $ this -> elementsStoredByStage [ $ stage ] ) ) { $ this -> elementsStoredByStage [ $ stage ] = [ ] ; } $ elementId = spl_object_hash ( $ element ) ; $ this -> elementsStoredByStage [ $ stage ] [ $ elementId ] = $ element ; return $ this ; } | Add element by stage . |
45,389 | public function createImage ( File $ file ) { $ fileMime = $ file -> getMimeType ( ) ; if ( 'application/octet-stream' === $ fileMime ) { $ imageSizeData = getimagesize ( $ file -> getPathname ( ) ) ; $ fileMime = $ imageSizeData [ 'mime' ] ; } if ( strpos ( $ fileMime , 'image/' ) !== 0 ) { throw new InvalidImageException ( ) ; } $ extension = $ file -> getExtension ( ) ; if ( ! $ extension && $ file instanceof UploadedFile ) { $ extension = $ file -> getClientOriginalExtension ( ) ; } $ image = $ this -> imageFactory -> create ( ) ; if ( ! isset ( $ imageSizeData ) ) { $ imageSizeData = getimagesize ( $ file -> getPathname ( ) ) ; } $ name = $ file -> getFilename ( ) ; $ image -> setWidth ( $ imageSizeData [ 0 ] ) -> setHeight ( $ imageSizeData [ 1 ] ) -> setContentType ( $ fileMime ) -> setSize ( $ file -> getSize ( ) ) -> setExtension ( $ extension ) -> setName ( $ name ) ; return $ image ; } | Given a single File assuming is an image create a new Image object containing all needed information . |
45,390 | public function resize ( ImageInterface $ image , $ height , $ width , $ type = ElcodiMediaImageResizeTypes :: FORCE_MEASURES ) { $ imageData = $ this -> fileManager -> downloadFile ( $ image ) -> getContent ( ) ; if ( ElcodiMediaImageResizeTypes :: NO_RESIZE === $ type ) { $ image -> setContent ( $ imageData ) ; return $ image ; } $ resizedImageData = $ this -> resizeAdapter -> resize ( $ imageData , $ height , $ width , $ type ) ; $ resizedFile = new File ( tempnam ( sys_get_temp_dir ( ) , '_generated' ) ) ; file_put_contents ( $ resizedFile , $ resizedImageData ) ; $ image = $ this -> createImage ( $ resizedFile ) ; $ image -> setContent ( $ resizedImageData ) ; unlink ( $ resizedFile ) ; return $ image ; } | Given an image resize it . |
45,391 | public function makeUse ( CouponOnUsedEvent $ event ) { $ coupon = $ event -> getCoupon ( ) ; $ coupon -> makeUse ( ) ; $ this -> couponObjectManager -> flush ( $ coupon ) ; } | This subscriber check if coupon can be still used by checking if number of coupons is already smaller than times it has been used . |
45,392 | public function addOrderLine ( OrderLineInterface $ orderLine ) { if ( ! $ this -> orderLines -> contains ( $ orderLine ) ) { $ this -> orderLines -> add ( $ orderLine ) ; } return $ this ; } | Add order line . |
45,393 | public function setCouponAmount ( MoneyInterface $ amount ) { $ this -> couponAmount = $ amount -> getAmount ( ) ; $ this -> couponCurrency = $ amount -> getCurrency ( ) ; return $ this ; } | Sets the Coupon amount with tax . |
45,394 | public function setShippingAmount ( MoneyInterface $ amount ) { $ this -> shippingAmount = $ amount -> getAmount ( ) ; $ this -> shippingCurrency = $ amount -> getCurrency ( ) ; return $ this ; } | Sets the Shipping amount with tax . |
45,395 | public function setPaymentStateLineStack ( StateLineStack $ paymentStateLineStack ) { $ this -> paymentStateLines = $ paymentStateLineStack -> getStateLines ( ) ; $ this -> paymentLastStateLine = $ paymentStateLineStack -> getLastStateLine ( ) ; return $ this ; } | Sets PaymentStateLineStack . |
45,396 | public function setShippingStateLineStack ( StateLineStack $ shippingStateLineStack ) { $ this -> shippingStateLines = $ shippingStateLineStack -> getStateLines ( ) ; $ this -> shippingLastStateLine = $ shippingStateLineStack -> getLastStateLine ( ) ; return $ this ; } | Sets ShippingStateLineStack . |
45,397 | public function findAddress ( $ customerId , $ addressId ) { $ response = $ this -> createQueryBuilder ( 'c' ) -> select ( [ 'c' , 'a' ] ) -> innerJoin ( 'c.addresses' , 'a' ) -> where ( 'c.id = :customerId' ) -> andWhere ( 'a.id = :addressId' ) -> setParameter ( 'customerId' , $ customerId ) -> setParameter ( 'addressId' , $ addressId ) -> setMaxResults ( 1 ) -> getQuery ( ) -> getResult ( ) ; if ( ! empty ( $ response ) ) { $ customer = reset ( $ response ) ; $ addresses = $ customer -> getAddresses ( ) ; if ( $ addresses ) { return $ addresses -> first ( ) ; } } return false ; } | Find a user address by it s id . |
45,398 | public function getExchangeRates ( ) { $ exchangeRates = [ ] ; $ response = $ this -> client -> get ( 'http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote' , [ 'query' => [ 'format' => 'json' , ] , ] ) -> json ( ) ; foreach ( $ response [ 'list' ] [ 'resources' ] as $ resource ) { $ fields = $ resource [ 'resource' ] [ 'fields' ] ; $ symbol = str_replace ( '=X' , '' , $ fields [ 'symbol' ] ) ; $ exchangeRates [ $ symbol ] = ( float ) $ fields [ 'price' ] ; } return $ exchangeRates ; } | Get the latest exchange rates . |
45,399 | public function getCheapestShippingMethod ( array $ shippingMethods ) { return array_reduce ( $ shippingMethods , function ( $ lowestPriceShippingMethod , ShippingMethod $ shippingMethod ) { $ shippingMethodPrice = $ shippingMethod -> getPrice ( ) ; if ( ! ( $ lowestPriceShippingMethod instanceof ShippingMethod ) || $ shippingMethodPrice -> isLessThan ( $ this -> currencyConverter -> convertMoney ( $ lowestPriceShippingMethod -> getPrice ( ) , $ shippingMethodPrice -> getCurrency ( ) ) ) ) { return $ shippingMethod ; } return $ lowestPriceShippingMethod ; } , null ) ; } | Given a set of shipping methods return the one with the lowest price . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.