idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
40,500
public static function extractAllCellReferencesInRange ( $ pRange = 'A1' ) { $ returnValue = array ( ) ; $ cellBlocks = explode ( ' ' , str_replace ( '$' , '' , strtoupper ( $ pRange ) ) ) ; foreach ( $ cellBlocks as $ cellBlock ) { if ( strpos ( $ cellBlock , ':' ) === FALSE && strpos ( $ cellBlock , ',' ) === FALSE )...
Extract all cell references in range
40,501
public static function SignUrl ( $ url , $ method , $ key , $ secret , $ params = null , $ body = null , $ signature_method = 'HMAC_SHA1' ) { $ options = array ( 'consumer_key' => $ key , 'consumer_secret' => $ secret ) ; $ params = $ params ? $ params : array ( ) ; OAuthStore :: instance ( "2Leg" , $ options ) ; $ req...
Given a URL return an OAuth signed URL . This will handle creating a timestamp and nonce
40,502
public function compile ( $ args , $ compiler , $ parameter , $ tag , $ function ) { if ( ! isset ( $ tag [ 5 ] ) || substr ( $ tag , - 5 ) != 'close' ) { $ _attr = $ this -> getAttributes ( $ compiler , $ args ) ; if ( $ _attr [ 'nocache' ] === true ) { $ compiler -> tag_nocache = true ; } unset ( $ _attr [ 'nocache' ...
Compiles code for the execution of block plugin
40,503
static function Init ( ) { require_once 'verysimple/Phreeze/Controller.php' ; require_once 'verysimple/HTTP/RequestUtil.php' ; if ( ! self :: $ IS_INITIALIZED ) { RequestUtil :: NormalizeUrlRewrite ( ) ; Controller :: $ SmartyViewPrefix = '' ; Controller :: $ DefaultRedirectMode = 'header' ; self :: $ IS_INITIALIZED = ...
Initialize the GlobalConfig object
40,504
static function GetInstance ( ) { if ( ! self :: $ IS_INITIALIZED ) self :: Init ( ) ; if ( ! self :: $ INSTANCE instanceof self ) self :: $ INSTANCE = new self ; return self :: $ INSTANCE ; }
Returns an instance of the GlobalConfig singleton
40,505
function GetPhreezer ( ) { if ( $ this -> phreezer == null ) { if ( self :: $ DEBUG_MODE ) { require_once ( "verysimple/Phreeze/ObserveToSmarty.php" ) ; $ observer = new ObserveToSmarty ( $ this -> GetRenderEngine ( ) ) ; $ this -> phreezer = new Phreezer ( self :: $ CONNECTION_SETTING , $ observer ) ; } else { $ this ...
Returns the Phreezer persistance layer
40,506
function close ( ) { if ( $ this -> _fileclosed ) { return true ; } $ res = $ this -> _storeWorkbook ( ) ; if ( $ this -> isError ( $ res ) ) { return $ this -> raiseError ( $ res -> getMessage ( ) ) ; } $ this -> _fileclosed = 1 ; return true ; }
Calls finalization methods . This method should always be the last one to be called on every workbook
40,507
function addFormat ( $ properties = array ( ) ) { $ format = new Spreadsheet_Excel_Writer_Format ( $ this -> _BIFF_version , $ this -> _xf_index , $ properties ) ; $ this -> _xf_index += 1 ; $ this -> _formats [ ] = $ format ; return $ format ; }
Add a new format to the Excel workbook . Also pass any properties to the Format constructor .
40,508
function setCustomColor ( $ index , $ red , $ green , $ blue ) { if ( $ index < 8 or $ index > 64 ) { return $ this -> raiseError ( "Color index $index outside range: 8 <= index <= 64" ) ; } if ( ( $ red < 0 or $ red > 255 ) || ( $ green < 0 or $ green > 255 ) || ( $ blue < 0 or $ blue > 255 ) ) { return $ this -> rais...
Change the RGB components of the elements in the colour palette .
40,509
function _storeOLEFile ( ) { if ( $ this -> _BIFF_version == 0x0600 ) { $ OLE = new OLE_PPS_File ( OLE :: Asc2Ucs ( 'Workbook' ) ) ; } else { $ OLE = new OLE_PPS_File ( OLE :: Asc2Ucs ( 'Book' ) ) ; } if ( $ this -> _tmp_dir != '' ) { $ OLE -> setTempDir ( $ this -> _tmp_dir ) ; } $ res = $ OLE -> init ( ) ; if ( $ thi...
Store the workbook in an OLE container
40,510
function _storeAllFonts ( ) { $ format = $ this -> _tmp_format ; $ font = $ format -> getFont ( ) ; for ( $ i = 1 ; $ i <= 5 ; $ i ++ ) { $ this -> _append ( $ font ) ; } $ fonts = array ( ) ; $ index = 6 ; $ key = $ format -> getFontKey ( ) ; $ fonts [ $ key ] = 0 ; $ total_formats = count ( $ this -> _formats ) ; for...
Store the Excel FONT records .
40,511
function _storeAllXfs ( ) { $ format = $ this -> _tmp_format ; for ( $ i = 0 ; $ i <= 14 ; $ i ++ ) { $ xf = $ format -> getXf ( 'style' ) ; $ this -> _append ( $ xf ) ; } $ xf = $ format -> getXf ( 'cell' ) ; $ this -> _append ( $ xf ) ; $ total_formats = count ( $ this -> _formats ) ; for ( $ i = 0 ; $ i < $ total_fo...
Write all XF records .
40,512
function _storePalette ( ) { $ aref = $ this -> _palette ; $ record = 0x0092 ; $ length = 2 + 4 * count ( $ aref ) ; $ ccv = count ( $ aref ) ; $ data = '' ; foreach ( $ aref as $ color ) { foreach ( $ color as $ byte ) { $ data .= pack ( "C" , $ byte ) ; } } $ header = pack ( "vvv" , $ record , $ length , $ ccv ) ; $ ...
Stores the PALETTE biff record .
40,513
public function getCategoryActiveProductsQueryBuilder ( CategoryInterface $ category = null , $ filter = null , $ option = null ) { $ queryBuilder = $ this -> getCategoryProductsQueryBuilder ( $ category ) ; $ queryBuilder -> leftJoin ( 'p.variations' , 'pv' ) -> andWhere ( 'p.parent IS NULL' ) -> andWhere ( 'p.enabled...
Returns active products for a given category .
40,514
protected function getCategoryProductsQueryBuilder ( CategoryInterface $ category = null ) { $ queryBuilder = $ this -> getRepository ( ) -> createQueryBuilder ( 'p' ) -> leftJoin ( 'p.image' , 'i' ) -> leftJoin ( 'p.gallery' , 'g' ) ; if ( $ category ) { $ queryBuilder -> leftJoin ( 'p.productCategories' , 'pc' ) -> a...
Returns QueryBuilder for products .
40,515
public function processCallback ( OrderInterface $ order , $ action ) { $ params = [ 'bank' => $ this -> getCode ( ) , 'reference' => $ order -> getReference ( ) , 'check' => $ this -> generateUrlCheck ( $ order ) , 'action' => $ action , ] ; $ url = $ this -> router -> generate ( $ this -> getOption ( 'url_callback' )...
Handle the callback .
40,516
public function indexAction ( $ form = null ) { $ form = $ form ? : $ this -> createForm ( BasketType :: class , $ this -> get ( 'sonata.basket' ) , [ 'validation_groups' => [ 'elements' ] , ] ) ; if ( ! $ form -> isSubmitted ( ) ) { if ( $ violations = $ this -> get ( 'validator' ) -> validate ( $ form ) ) { $ violati...
Shows the basket .
40,517
public function updateAction ( ) { $ form = $ this -> createForm ( BasketType :: class , $ this -> get ( 'sonata.basket' ) , [ 'validation_groups' => [ 'elements' ] ] ) ; $ form -> handleRequest ( $ this -> getCurrentRequest ( ) ) ; if ( $ form -> isValid ( ) ) { $ basket = $ form -> getData ( ) ; $ basket -> reset ( f...
Update basket form rendering & saving .
40,518
public function addProductAction ( ) { $ request = $ this -> getCurrentRequest ( ) ; $ params = $ request -> get ( 'add_basket' ) ; if ( 'POST' !== $ request -> getMethod ( ) ) { throw new MethodNotAllowedException ( [ 'POST' ] ) ; } $ product = $ this -> get ( 'sonata.product.set.manager' ) -> findOneBy ( [ 'id' => $ ...
Adds a product to the basket .
40,519
public function getBasket ( ) { if ( ! $ this -> basket ) { try { $ this -> basket = $ this -> basketFactory -> load ( $ this -> customerSelector -> get ( ) ) ; } catch ( \ Exception $ e ) { throw $ e ; } } return $ this -> basket ; }
Get the basket .
40,520
public function errorAction ( ) { try { $ order = $ this -> getPaymentHandler ( ) -> handleError ( $ this -> getCurrentRequest ( ) , $ this -> getBasket ( ) ) ; } catch ( EntityNotFoundException $ ex ) { throw new NotFoundHttpException ( $ ex -> getMessage ( ) ) ; } catch ( InvalidTransactionException $ ex ) { throw ne...
This action is called by the user after the sendbank In most case the order is already cancelled by a previous callback .
40,521
public function sendbankAction ( ) { $ basket = $ this -> getBasket ( ) ; if ( 'POST' !== $ this -> getCurrentRequest ( ) -> getMethod ( ) ) { return $ this -> redirect ( $ this -> generateUrl ( 'sonata_basket_index' ) ) ; } if ( ! $ basket -> isValid ( ) ) { $ this -> get ( 'session' ) -> getFlashBag ( ) -> set ( 'err...
this action redirect the user to the bank .
40,522
public function callbackAction ( ) { try { $ response = $ this -> getPaymentHandler ( ) -> getPaymentCallbackResponse ( $ this -> getCurrentRequest ( ) ) ; } catch ( EntityNotFoundException $ ex ) { throw new NotFoundHttpException ( $ ex -> getMessage ( ) ) ; } catch ( InvalidTransactionException $ ex ) { throw new Una...
this action handler the callback sent from the bank .
40,523
public function renderPropertiesAction ( ProductInterface $ product ) { $ provider = $ this -> get ( 'sonata.product.pool' ) -> getProvider ( $ product ) ; return $ this -> render ( sprintf ( '%s:properties.html.twig' , $ provider -> getBaseControllerName ( ) ) , [ 'product' => $ product , ] ) ; }
Renders product properties .
40,524
protected function getFilterUri ( $ currentUri , $ filter , $ option ) { return sprintf ( '%s?filter=%s&option=%s' , false !== ( $ pos = strpos ( $ currentUri , '?' ) ) ? substr ( $ currentUri , 0 , $ pos ) : $ currentUri , $ filter , $ option ) ; }
Generates the filter uri .
40,525
protected function getCategoryTitle ( CategoryInterface $ category , $ limit = 500 ) { $ count = $ this -> categoryManager -> getProductCount ( $ category , $ limit ) ; return sprintf ( '%s <span class="badge pull-right">%d%s</span>' , $ category -> getName ( ) , $ count , $ count > $ limit ? '+' : '' ) ; }
Gets the HTML associated with the category menu title .
40,526
public function indexAction ( ) { $ pager = $ this -> get ( 'sonata.classification.manager.collection' ) -> getRootCollectionsPager ( $ this -> getCurrentRequest ( ) -> get ( 'page' ) ) ; return $ this -> render ( 'SonataProductBundle:Collection:index.html.twig' , [ 'pager' => $ pager , ] ) ; }
List the main collections .
40,527
public function viewAction ( $ collectionId , $ slug ) { $ collection = $ this -> get ( 'sonata.classification.manager.collection' ) -> findOneBy ( [ 'id' => $ collectionId ] ) ; if ( ! $ collection ) { throw new NotFoundHttpException ( sprintf ( 'Unable to find the collection with id=%d' , $ collectionId ) ) ; } retur...
Display one collection .
40,528
public function listSubCollectionsAction ( $ collectionId ) { $ pager = $ this -> get ( 'sonata.classification.manager.collection' ) -> getSubCollectionsPager ( $ collectionId , $ this -> getCurrentRequest ( ) -> get ( 'page' ) ) ; return $ this -> render ( 'SonataProductBundle:Collection:list_sub_collections.html.twig...
List collections from one collections .
40,529
public function listProductsAction ( $ collectionId ) { $ pager = $ this -> get ( 'sonata.product.set.manager' ) -> getProductsByCollectionIdPager ( $ collectionId , $ this -> getCurrentRequest ( ) -> get ( 'page' ) ) ; return $ this -> render ( 'SonataProductBundle:Collection:list_products.html.twig' , [ 'pager' => $ ...
List the product related to one collection .
40,530
public function transformFromOrder ( OrderInterface $ order , InvoiceInterface $ invoice ) { $ event = new OrderTransformEvent ( $ order ) ; $ this -> eventDispatcher -> dispatch ( TransformerEvents :: PRE_ORDER_TO_INVOICE_TRANSFORM , $ event ) ; $ invoice -> setName ( $ order -> getBillingName ( ) ) ; $ invoice -> set...
Transforms an order into an invoice .
40,531
protected function createInvoiceElementFromOrderElement ( OrderElementInterface $ orderElement ) { $ invoice = $ this -> invoiceElementManager -> create ( ) ; $ invoice -> setOrderElement ( $ orderElement ) ; $ invoice -> setDescription ( $ orderElement -> getDescription ( ) ) ; $ invoice -> setDesignation ( $ orderEle...
Creates an InvoiceElement based on an OrderElement .
40,532
public function validate ( $ basket , Constraint $ constraint ) { foreach ( $ basket -> getBasketElements ( ) as $ pos => $ basketElement ) { $ errorElement = new ErrorElement ( $ basket , $ this -> constraintValidatorFactory , $ this -> context , $ this -> context -> getGroup ( ) ) ; $ errorElement -> with ( 'basketEl...
The validator asks each product repository to validate the related basket element .
40,533
public function defineAddBasketForm ( ProductInterface $ product , FormBuilder $ formBuilder , $ showQuantity = true , array $ options = [ ] ) { $ basketElement = $ this -> createBasketElement ( $ product ) ; $ formBuilder -> setData ( $ basketElement ) -> add ( 'productId' , 'hidden' ) ; if ( $ showQuantity ) { $ form...
This function return the form used in the product view page .
40,534
public function basketMergeProduct ( BasketInterface $ basket , ProductInterface $ product , BasketElementInterface $ newBasketElement ) { $ event = new AddBasketElementEvent ( $ basket , $ newBasketElement , $ product , $ this ) ; $ this -> getEventDispatcher ( ) -> dispatch ( BasketEvents :: PRE_MERGE_PRODUCT , $ eve...
Merge a product with another when the product is already present into the basket .
40,535
public function putProductAction ( $ id , $ provider , Request $ request ) { return $ this -> handleWriteProduct ( $ provider , $ request , $ id ) ; }
Updates a product .
40,536
public function deleteProductAction ( $ id ) { $ product = $ this -> getProduct ( $ id ) ; $ manager = $ this -> productPool -> getManager ( $ product ) ; try { $ manager -> delete ( $ product ) ; } catch ( \ Exception $ e ) { return FOSRestView :: create ( [ 'error' => $ e -> getMessage ( ) ] , 400 ) ; } return [ 'del...
Deletes a product .
40,537
protected function handleWriteProduct ( $ provider , $ request , $ id = null ) { $ product = $ id ? $ this -> getProduct ( $ id ) : null ; try { $ manager = $ this -> productPool -> getManager ( $ provider ) ; } catch ( \ RuntimeException $ e ) { throw new NotFoundHttpException ( $ e -> getMessage ( ) , $ e ) ; } $ for...
Write a product this method is used by both POST and PUT action methods .
40,538
public static function formatAddress ( array $ address , $ sep = ', ' ) { $ address = array_merge ( [ 'firstname' => '' , 'lastname' => '' , 'address1' => '' , 'address2' => '' , 'address3' => '' , 'postcode' => '' , 'city' => '' , 'country_code' => '' , ] , $ address ) ; $ values = array_map ( 'trim' , [ sprintf ( '%s...
Formats an address in an array form .
40,539
public function build ( BasketInterface $ basket ) { $ basket -> setProductPool ( $ this -> productPool ) ; foreach ( $ basket -> getBasketElements ( ) as $ basketElement ) { if ( null === $ basketElement -> getProduct ( ) ) { if ( null === $ basketElement -> getProductCode ( ) ) { throw new \ RuntimeException ( 'The p...
Build a basket .
40,540
protected function getOrder ( ConsumerEvent $ event ) { $ orderId = $ event -> getMessage ( ) -> getValue ( 'order_id' ) ; $ order = $ this -> orderManager -> getOrder ( $ orderId ) ; if ( ! $ order ) { throw new \ RuntimeException ( sprintf ( 'Unable to retrieve Order %d' , $ orderId ) ) ; } return $ order ; }
Get the related Order .
40,541
protected function getTransaction ( ConsumerEvent $ event ) { $ transactionId = $ event -> getMessage ( ) -> getValue ( 'transaction_id' ) ; $ transaction = $ this -> transactionManager -> findOneBy ( [ 'id' => $ transactionId , ] ) ; if ( ! $ transaction ) { throw new \ RuntimeException ( sprintf ( 'Unable to retrieve...
Get the related Transaction .
40,542
protected function checkAccess ( CustomerInterface $ customer ) { if ( ! ( $ user = $ this -> getUser ( ) ) || ! $ customer -> getUser ( ) || $ customer -> getUser ( ) -> getId ( ) !== $ user -> getId ( ) ) { throw new AccessDeniedException ( ) ; } }
Checks that the current logged in user has access to given invoice .
40,543
public function setProduct ( ProductInterface $ product ) { $ this -> productId = $ product -> getId ( ) ; $ this -> product = $ product ; }
Set the related product .
40,544
public function load ( array $ configs , ContainerBuilder $ container ) { $ processor = new Processor ( ) ; $ configuration = new Configuration ( ) ; $ config = $ processor -> processConfiguration ( $ configuration , $ configs ) ; $ bundles = $ container -> getParameter ( 'kernel.bundles' ) ; $ loader = new XmlFileLoad...
Loads the product configuration .
40,545
public function findLastActiveProducts ( $ limit = 5 ) { return $ this -> createQueryBuilder ( 'p' ) -> select ( 'p' , 'i' , 'g' ) -> distinct ( ) -> leftJoin ( 'p.image' , 'i' ) -> leftJoin ( 'p.gallery' , 'g' ) -> leftJoin ( 'p.variations' , 'pv' ) -> andWhere ( 'p.parent IS NULL' ) -> andWhere ( 'p.enabled = :enable...
Returns an array of last products .
40,546
public function isRequestValid ( TransactionInterface $ transaction ) { $ checkUrl = $ transaction -> get ( 'check' ) ; $ checkPrivate = $ this -> generateUrlCheck ( $ transaction -> getOrder ( ) ) ; return $ checkUrl === $ checkPrivate ; }
return true if the request contains a valid check parameter .
40,547
public function applyTransactionId ( TransactionInterface $ transaction ) { $ transactionId = $ transaction -> get ( 'txn_id' , null ) ; if ( ! $ transactionId ) { $ transactionId = - 1 ; } $ transaction -> setTransactionId ( $ transactionId ) ; }
return the transaction_id sent by the bank .
40,548
public function getOrderReference ( TransactionInterface $ transaction ) { $ order = $ transaction -> get ( 'order' , null ) ; if ( $ this -> getLogger ( ) ) { $ this -> getLogger ( ) -> notice ( sprintf ( '[BasePaypalPayment::loadOrder] order=%s' , $ order ) ) ; } return $ order ; }
return the order reference from the transaction object .
40,549
public function checkPaypalFiles ( ) { $ key_file = $ this -> getOption ( 'key_file' ) ; $ cert_file = $ this -> getOption ( 'cert_file' ) ; $ paypal_cert_file = $ this -> getOption ( 'paypal_cert_file' ) ; $ openssl = $ this -> getOption ( 'openssl' ) ; if ( ! file_exists ( $ key_file ) ) { if ( $ this -> getLogger ( ...
Check openssl configuration throw an RuntimeException if something is wrong .
40,550
public function encryptViaBuffer ( $ hash ) { $ this -> checkPaypalFiles ( ) ; $ key_file = $ this -> getOption ( 'key_file' ) ; $ cert_file = $ this -> getOption ( 'cert_file' ) ; $ paypal_cert_file = $ this -> getOption ( 'paypal_cert_file' ) ; $ openssl = $ this -> getOption ( 'openssl' ) ; $ openssl_cmd = "$openssl...
Encrypt paypal information using openssl with a buffer .
40,551
public function encryptViaFile ( $ hash ) { $ this -> checkPaypalFiles ( ) ; $ key_file = $ this -> getOption ( 'key_file' ) ; $ cert_file = $ this -> getOption ( 'cert_file' ) ; $ openssl = $ this -> getOption ( 'openssl' ) ; $ paypal_cert_file = $ this -> getOption ( 'paypal_cert_file' ) ; $ filename = tempnam ( sys_...
Encrypt paypal information using openssl with a temporary file .
40,552
public function renderAddress ( \ Twig_Environment $ environment , $ address , $ showName = true , $ showEdit = false , $ context = null ) { $ requiredAddressKeys = [ 'firstname' , 'lastname' , 'address1' , 'postcode' , 'city' , 'country_code' ] ; if ( ! ( $ address instanceof AddressInterface ) && ( ! \ is_array ( $ a...
Gets the HTML of an address .
40,553
public function isAddressDeliverable ( AddressInterface $ address , BasketInterface $ basket ) { $ methods = $ this -> deliverySelector -> getAvailableMethods ( $ basket , $ address ) ; return \ count ( $ methods ) > 0 ? true : false ; }
Returns if address can deliver the given basket .
40,554
public function getTitleName ( ) { $ list = self :: getTitlesList ( ) ; return isset ( $ list [ $ this -> title ] ) ? $ list [ $ this -> title ] : '' ; }
Get title name .
40,555
public function indexAction ( ) { $ request = $ this -> getCurrentRequest ( ) ; $ page = $ request -> get ( 'page' , 1 ) ; $ displayMax = $ request -> get ( 'max' , 9 ) ; $ displayMode = $ request -> get ( 'mode' , 'grid' ) ; $ filter = $ request -> get ( 'filter' ) ; $ option = $ request -> get ( 'option' ) ; if ( ! \...
Index action for catalog .
40,556
protected function retrieveCategoryFromQueryString ( ) { $ request = $ this -> getCurrentRequest ( ) ; $ categoryId = $ request -> get ( 'category_id' ) ; $ categorySlug = $ request -> get ( 'category_slug' ) ; if ( ! $ categoryId || ! $ categorySlug ) { return null ; } return $ this -> getCategoryManager ( ) -> findOn...
Retrieve Category from its id and slug if any .
40,557
protected function getBasketDeliveryCountries ( ) { $ countries = [ ] ; foreach ( $ this -> basket -> getBasketElements ( ) as $ basketElement ) { $ product = $ basketElement -> getProduct ( ) ; foreach ( $ product -> getDeliveries ( ) as $ delivery ) { $ code = $ delivery -> getCountryCode ( ) ; if ( ! isset ( $ count...
Returns basket elements delivery countries .
40,558
public function addMethod ( PaymentInterface $ instance ) { if ( null === $ instance -> getCode ( ) ) { throw new \ RuntimeException ( sprintf ( 'Payment handler of class %s must return a code on getCode method. Please refer to the documentation (https://sonata-project.org/bundles/ecommerce/master/doc/reference/bundles...
add a payment method into the pool .
40,559
public function getMethod ( $ code ) { return isset ( $ this -> methods [ $ code ] ) ? $ this -> methods [ $ code ] : null ; }
return a PaymentInterface Object .
40,560
public function getBasketsAction ( ParamFetcherInterface $ paramFetcher ) { $ orderByQueryParam = new QueryParam ( ) ; $ orderByQueryParam -> name = 'orderBy' ; $ orderByQueryParam -> requirements = 'ASC|DESC' ; $ orderByQueryParam -> nullable = true ; $ orderByQueryParam -> strict = true ; $ orderByQueryParam -> descr...
Returns a paginated list of baskets .
40,561
public function deleteBasketAction ( $ id ) { $ basket = $ this -> getBasket ( $ id ) ; try { $ this -> basketManager -> delete ( $ basket ) ; } catch ( \ Exception $ e ) { return FOSRestView :: create ( [ 'error' => $ e -> getMessage ( ) ] , 400 ) ; } return [ 'deleted' => true ] ; }
Deletes a basket .
40,562
public function putBasketBasketelementsAction ( $ basketId , $ elementId , Request $ request ) { return $ this -> handleWriteBasketElement ( $ basketId , $ request , $ elementId ) ; }
Updates a basket element of a basket .
40,563
public function deleteBasketBasketelementsAction ( $ basketId , $ elementId ) { $ basket = $ this -> getBasket ( $ basketId ) ; $ this -> basketBuilder -> build ( $ basket ) ; $ elements = $ basket -> getBasketElements ( ) ; foreach ( $ elements as $ key => $ basketElement ) { if ( $ basketElement -> getId ( ) === $ el...
Deletes a basket element from a basket .
40,564
protected function handleWriteBasket ( $ request , $ id = null ) { $ basket = $ id ? $ this -> getBasket ( $ id ) : null ; $ form = $ this -> formFactory -> createNamed ( null , 'sonata_basket_api_form_basket' , $ basket , [ 'csrf_protection' => false , ] ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isVal...
Write a basket this method is used by both POST and PUT action methods .
40,565
protected function handleWriteBasketElement ( $ basketId , $ request , $ elementId = null ) { $ basket = $ this -> getBasket ( $ basketId ) ; $ this -> basketBuilder -> build ( $ basket ) ; $ productId = $ request -> request -> get ( 'productId' ) ; $ product = $ this -> getProduct ( $ productId ) ; $ productPool = $ b...
Write a basket element this method is used by both POST and PUT action methods .
40,566
protected function checkExistingCustomerBasket ( $ customerId ) { $ basket = $ this -> basketManager -> findOneBy ( [ 'customer' => $ customerId ] ) ; if ( $ basket instanceof BasketInterface ) { throw new HttpException ( 400 , sprintf ( 'Customer (%d) already has a basket' , $ customerId ) ) ; } }
Throws an exception if it already exists a basket with a specific customer id .
40,567
public function getTransformer ( $ type ) { return isset ( $ this -> methods [ $ type ] ) ? $ this -> methods [ $ type ] : null ; }
return a Transformer Object .
40,568
public function paymentAction ( ) { $ order = $ this -> checkRequest ( ) ; return $ this -> render ( 'SonataPaymentBundle:Payment:debug.html.twig' , [ 'order' => $ order , 'check' => $ this -> getCurrentRequest ( ) -> get ( 'check' ) , ] ) ; }
User choice action .
40,569
public function processPaymentAction ( ) { $ order = $ this -> checkRequest ( ) ; return $ this -> getDebugPayment ( ) -> processCallback ( $ order , $ this -> getCurrentRequest ( ) -> get ( 'action' ) ) ; }
Process the User choice .
40,570
protected function checkRequest ( ) { if ( 'prod' === $ this -> getKernel ( ) -> getEnvironment ( ) ) { throw new \ RuntimeException ( 'Debug Payment is not authorized in production environment.' ) ; } $ request = $ this -> getCurrentRequest ( ) ; $ reference = $ request -> get ( 'reference' ) ; $ order = $ this -> get...
Check the Request and return the current Order .
40,571
public function alterPage ( SeoPageInterface $ seoPage , ProductInterface $ product ) { $ seoPage -> addMeta ( 'name' , 'twitter:card' , 'product' ) -> addMeta ( 'name' , 'twitter:title' , $ product -> getName ( ) ) -> addMeta ( 'name' , 'twitter:description' , substr ( ( string ) $ product -> getDescription ( ) , 0 , ...
Add the meta information .
40,572
protected function getShaSign ( array $ params , $ out = false ) { uksort ( $ params , 'strcasecmp' ) ; $ shaKey = $ this -> getOption ( 'sha' . ( $ out ? '-out' : '' ) . '_key' ) ; $ shasignStr = '' ; foreach ( $ params as $ key => $ param ) { if ( null !== $ param && '' !== $ param ) { $ shasignStr .= strtoupper ( $ ...
Signs the payment transaction .
40,573
protected function getFormParameters ( OrderInterface $ order ) { return [ 'PSPID' => $ this -> getOption ( 'pspid' ) , 'orderId' => $ order -> getReference ( ) , 'amount' => $ order -> getTotalInc ( ) * 100 , 'currency' => $ order -> getCurrency ( ) -> getLabel ( ) , 'language' => $ order -> getLocale ( ) , 'CN' => $ ...
Returns form parameters for sendbank .
40,574
public function addressesAction ( ) { $ customer = $ this -> getCustomer ( ) ; $ typeCodes = BaseAddress :: getTypesList ( ) ; $ addresses = [ $ typeCodes [ AddressInterface :: TYPE_DELIVERY ] => [ ] , $ typeCodes [ AddressInterface :: TYPE_BILLING ] => [ ] , $ typeCodes [ AddressInterface :: TYPE_CONTACT ] => [ ] , ] ...
Lists customer s addresses .
40,575
protected function updateAddress ( $ id = null ) { $ request = $ this -> getCurrentRequest ( ) ; $ customer = $ this -> getCustomer ( ) ; if ( null === $ id ) { $ form = $ this -> createForm ( AddressType :: class ) ; } else { $ address = $ this -> getAddressManager ( ) -> findOneBy ( [ 'id' => $ id ] ) ; $ this -> che...
Updates or create an address .
40,576
protected function getSessionVarName ( CustomerInterface $ customer = null ) { if ( null === $ customer || null === $ customer -> getId ( ) ) { return self :: SESSION_BASE_NAME . 'new' ; } return self :: SESSION_BASE_NAME . $ customer -> getId ( ) ; }
Get the name of the session variable .
40,577
protected function clearSession ( CustomerInterface $ customer ) { $ this -> session -> remove ( $ this -> getSessionVarName ( $ customer ) ) ; $ this -> session -> remove ( $ this -> getSessionVarName ( ) ) ; }
Clears the baskets in session .
40,578
public static function renderDir ( $ dir , array $ parameters ) { foreach ( new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ dir ) , \ RecursiveIteratorIterator :: LEAVES_ONLY ) as $ file ) { if ( $ file -> isFile ( ) ) { static :: renderFile ( ( string ) $ file , $ parameters ) ; } } }
Renders a directory recursively .
40,579
public function getProductPrice ( ProductInterface $ product , CurrencyInterface $ currency , $ vat = false ) { return $ this -> productPool -> getProvider ( $ product ) -> calculatePrice ( $ product , $ currency , $ vat , 1 ) ; }
Return the calculated price of the product .
40,580
public function getFormAddBasket ( ProductInterface $ product ) { $ formBuilder = $ this -> formFactory -> createNamedBuilder ( 'add_basket' , 'form' , null , [ 'data_class' => $ this -> basketElementClass , 'csrf_protection' => false , ] ) ; $ this -> productPool -> getProvider ( $ product ) -> defineAddBasketForm ( $...
Returns a add to basket form for a specified product .
40,581
public function deleteCustomerAction ( $ id ) { $ customer = $ this -> getCustomer ( $ id ) ; try { $ this -> customerManager -> delete ( $ customer ) ; } catch ( \ Exception $ e ) { return FOSRestView :: create ( [ 'error' => $ e -> getMessage ( ) ] , 400 ) ; } return [ 'deleted' => true ] ; }
Deletes a customer .
40,582
public function getCustomerOrdersAction ( $ id ) { $ customer = $ this -> getCustomer ( $ id ) ; return $ this -> orderManager -> findBy ( [ 'customer' => $ customer ] ) ; }
Retrieves a specific customer s orders .
40,583
public function postCustomerAddressAction ( $ id , Request $ request ) { $ customer = $ id ? $ this -> getCustomer ( $ id ) : null ; $ form = $ this -> formFactory -> createNamed ( null , 'sonata_customer_api_form_address' , null , [ 'csrf_protection' => false , ] ) ; $ form -> handleRequest ( $ request ) ; if ( $ form...
Adds a customer address .
40,584
protected function handleWriteCustomer ( $ request , $ id = null ) { $ customer = $ id ? $ this -> getCustomer ( $ id ) : null ; $ form = $ this -> formFactory -> createNamed ( null , 'sonata_customer_api_form_customer' , $ customer , [ 'csrf_protection' => false , ] ) ; $ form -> handleRequest ( $ request ) ; if ( $ f...
Write a customer this method is used by both POST and PUT action methods .
40,585
public function get ( ) { $ customer = null ; $ user = null ; if ( true === $ this -> securityContext -> isGranted ( 'IS_AUTHENTICATED_REMEMBERED' ) ) { $ user = $ this -> securityContext -> getToken ( ) -> getUser ( ) ; if ( ! $ user instanceof UserInterface ) { throw new \ RuntimeException ( 'User must be an instance...
Get the customer .
40,586
public function deleteAddressAction ( $ id ) { $ address = $ this -> getAddress ( $ id ) ; try { $ this -> addressManager -> delete ( $ address ) ; } catch ( \ Exception $ e ) { return FOSRestView :: create ( [ 'error' => $ e -> getMessage ( ) ] , 400 ) ; } return [ 'deleted' => true ] ; }
Deletes an address .
40,587
protected function handleWriteAddress ( $ request , $ id = null ) { $ address = $ id ? $ this -> getAddress ( $ id ) : null ; $ form = $ this -> formFactory -> createNamed ( null , 'sonata_customer_api_form_address' , $ address , [ 'csrf_protection' => false , ] ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -...
Write an address this method is used by both POST and PUT action methods .
40,588
public static function parseByAggregate ( $ money , $ forceCurrency = null , array $ parsers = [ ] ) { $ parser = new AggregateMoneyParser ( $ parsers ) ; return self :: parseByParser ( $ parser , $ money , $ forceCurrency ) ; }
Parse by aggregate .
40,589
public static function parseByBitcoin ( $ money , $ forceCurrency = null , $ fractionDigits = 2 ) { $ parser = new BitcoinMoneyParser ( $ fractionDigits ) ; return self :: parseByParser ( $ parser , $ money , $ forceCurrency ) ; }
Parse by bitcoin .
40,590
public static function parseByDecimal ( $ money , $ forceCurrency = null , Currencies $ currencies = null ) { $ parser = new DecimalMoneyParser ( $ currencies ? : static :: getCurrencies ( ) ) ; return self :: parseByParser ( $ parser , $ money , $ forceCurrency ) ; }
Parse by decimal .
40,591
public static function parseByIntl ( $ money , $ forceCurrency = null , $ locale = null , Currencies $ currencies = null , $ style = NumberFormatter :: CURRENCY ) { $ numberFormatter = new NumberFormatter ( $ locale ? : static :: getLocale ( ) , $ style ) ; $ parser = new IntlMoneyParser ( $ numberFormatter , $ currenc...
Parse by intl .
40,592
public static function parseByIntlLocalizedDecimal ( $ money , $ forceCurrency , $ locale = null , Currencies $ currencies = null , $ style = NumberFormatter :: DECIMAL ) { $ numberFormatter = new NumberFormatter ( $ locale ? : static :: getLocale ( ) , $ style ) ; $ parser = new IntlLocalizedDecimalParser ( $ numberFo...
Parse by intl localized decimal .
40,593
public static function parseByParser ( MoneyParser $ parser , $ money , $ forceCurrency = null ) { return static :: convert ( $ parser -> parse ( $ money , $ forceCurrency ) ) ; }
Parse by parser .
40,594
private static function registerAggregations ( BladeCompiler $ compiler ) { $ compiler -> directive ( 'money_min' , function ( $ expression ) { return "<?php echo money_min(${expression}); ?>" ; } ) ; $ compiler -> directive ( 'money_max' , function ( $ expression ) { return "<?php echo money_max(${expression}); ?>" ; ...
Register aggregations .
40,595
private static function registerParsers ( BladeCompiler $ compiler ) { $ compiler -> directive ( 'money_parse' , function ( $ expression ) { return "<?php echo money_parse(${expression}); ?>" ; } ) ; $ compiler -> directive ( 'money_parse_by_bitcoin' , function ( $ expression ) { return "<?php echo money_parse_by_bitco...
Register parsers .
40,596
private static function getArguments ( array $ arguments = [ ] ) { $ args = [ ] ; foreach ( $ arguments as $ argument ) { $ args [ ] = $ argument instanceof self ? $ argument -> getMoney ( ) : $ argument ; } return $ args ; }
Get arguments .
40,597
private static function convertResult ( $ result ) { if ( ! is_array ( $ result ) ) { return self :: convert ( $ result ) ; } $ results = [ ] ; foreach ( $ result as $ item ) { $ results [ ] = self :: convert ( $ item ) ; } return $ results ; }
Convert result .
40,598
public function formatByBitcoin ( $ fractionDigits = 2 , Currencies $ currencies = null ) { $ formatter = new BitcoinMoneyFormatter ( $ fractionDigits , $ currencies ? : new BitcoinCurrencies ( ) ) ; return $ this -> formatByFormatter ( $ formatter ) ; }
Format by bitcoin .
40,599
public function formatByDecimal ( Currencies $ currencies = null ) { $ formatter = new DecimalMoneyFormatter ( $ currencies ? : static :: getCurrencies ( ) ) ; return $ this -> formatByFormatter ( $ formatter ) ; }
Format by decimal .