idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
7,000
public function getLogById ( $ id ) { $ log = $ this -> createQueryBuilder ( ) -> select ( 'l.*' ) -> from ( $ this -> tableName , 'l' ) -> where ( 'l.id = :id' ) -> setParameter ( ':id' , $ id ) -> execute ( ) -> fetch ( ) ; if ( false !== $ log ) { return new Log ( $ log ) ; } }
Retrieve a log entry by his ID .
7,001
public function getLastLog ( ) { $ log = $ this -> createQueryBuilder ( ) -> select ( 'l.*' ) -> from ( $ this -> tableName , 'l' ) -> orderBy ( 'l.id' , 'DESC' ) -> setMaxResults ( 1 ) -> execute ( ) -> fetch ( ) ; if ( false !== $ log ) { return new Log ( $ log ) ; } }
Retrieve last log entry .
7,002
public function getSimilarLogsQueryBuilder ( Log $ log ) { return $ this -> createQueryBuilder ( ) -> select ( 'l.id, l.channel, l.level, l.level_name, l.message, l.datetime' ) -> from ( $ this -> tableName , 'l' ) -> andWhere ( 'l.message = :message' ) -> andWhere ( 'l.channel = :channel' ) -> andWhere ( 'l.level = :l...
Retrieve similar logs of the given one .
7,003
public function getLogsLevel ( ) { $ levels = $ this -> createQueryBuilder ( ) -> select ( 'l.level, l.level_name, COUNT(l.id) AS count' ) -> from ( $ this -> tableName , 'l' ) -> groupBy ( 'l.level, l.level_name' ) -> orderBy ( 'l.level' , 'DESC' ) -> execute ( ) -> fetchAll ( ) ; $ normalizedLevels = array ( ) ; fore...
Returns a array of levels with count entries used by logs .
7,004
public function postAction ( Request $ request , $ productId ) { $ locale = $ this -> getLocale ( $ request ) ; $ mediaId = $ request -> get ( 'mediaId' , '' ) ; try { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ product = $ this -> getProductManager ( ) -> findByIdAndLocale ( $ productId , $ locale ) ; $ med...
Adds a new media to the product .
7,005
public function putAction ( Request $ request , $ productId ) { $ mediaIds = $ request -> get ( 'mediaIds' ) ; if ( null === $ mediaIds || ! is_array ( $ mediaIds ) ) { throw new ProductException ( 'No media ids given.' ) ; } $ product = $ this -> getProductRepository ( ) -> find ( $ productId ) ; if ( ! $ product ) { ...
Updates media of a product .
7,006
public function deleteAction ( $ productId , $ mediaId ) { $ product = $ this -> getProductRepository ( ) -> find ( $ productId ) ; if ( ! $ product ) { throw new EntityNotFoundException ( $ this -> getProductEntityName ( ) , $ productId ) ; } $ this -> getProductMediaManager ( ) -> delete ( $ product , [ $ mediaId ] )...
Removes a media from the relation .
7,007
private function removeDefaultPrices ( Product $ product ) { $ defaultPrices = [ ] ; foreach ( $ product -> getPrices ( ) as $ price ) { if ( $ price -> getId ( ) === null ) { $ defaultPrices [ ] = $ price ; } } foreach ( $ defaultPrices as $ price ) { $ product -> removePrice ( $ price -> getEntity ( ) ) ; } }
Removes default prices from product .
7,008
public function analyzeHeaders ( string $ rawMQTTHeaders , ClientInterface $ client ) : ReadableContentInterface { if ( $ rawMQTTHeaders === '' ) { $ this -> logger -> debug ( 'Empty headers, returning an empty object' ) ; return new EmptyReadableResponse ( $ this -> logger ) ; } $ controlPacketType = \ ord ( $ rawMQTT...
Will check within all the Readable objects whether one of those is the correct packet we are looking for
7,009
public function isValidShopProduct ( $ defaultCurrency ) { $ isValid = false ; if ( method_exists ( $ this , 'getPrices' ) && $ this -> getStatus ( ) -> getId ( ) == Status :: ACTIVE && $ this -> getPrices ( ) && count ( $ this -> getPrices ( ) ) > 0 && $ this -> hasPriceInDefaultCurrency ( $ this -> getPrices ( ) , $ ...
Helper method to check if the product is a valid shop product .
7,010
private function hasPriceInDefaultCurrency ( $ prices , $ defaultCurrency ) { foreach ( $ prices as $ price ) { if ( $ price -> getCurrency ( ) -> getCode ( ) === $ defaultCurrency ) { return true ; } } return false ; }
Checks if price in default currency exists .
7,011
protected function registerRoutes ( Router $ router ) { $ debug = $ this -> app -> make ( MailDebugManager :: class ) ; $ router -> get ( 'mail-debug/{file}' , function ( $ file ) use ( $ debug ) { if ( file_exists ( $ path = $ debug -> storage ( ) . '/' . $ file ) ) { include $ path ; return ; } return abort ( 404 ) ;...
Register the Mail Debug Routes .
7,012
private function parseContentToArray ( ProductTranslation $ productTranslation ) { $ routePath = null ; if ( $ productTranslation -> getRoute ( ) ) { $ routePath = $ productTranslation -> getRoute ( ) -> getPath ( ) ; } return [ 'title' => $ productTranslation -> getContentTitle ( ) , 'routePath' => $ routePath , ] ; }
Parses product content data to an array .
7,013
private function setTopicName ( string $ topicName ) : self { $ this -> generalRulesCheck ( $ topicName ) ; if ( strpbrk ( $ topicName , '#+' ) !== false ) { throw new \ InvalidArgumentException ( 'Topic names can not contain wildcard characters' ) ; } $ this -> topicName = $ topicName ; return $ this ; }
Contains the name of the TopicFilter Filter
7,014
public static function resetTrap ( ) { if ( ! self :: $ registered ) { throw new RuntimeException ( 'Signal handler has not been registered' ) ; } if ( ! pcntl_signal_dispatch ( ) ) { throw new RuntimeException ( sprintf ( 'Call to pcntl_signal_dispatch() failed (PHP error: "%s")' , @ error_get_last ( ) [ 'message' ] )...
Relinquish control to PHP .
7,015
final public function setPacketIdentifierFromRawHeaders ( string $ rawMQTTHeaders ) : self { $ this -> packetIdentifier = new PacketIdentifier ( Utilities :: convertBinaryStringToNumber ( $ rawMQTTHeaders { 2 } . $ rawMQTTHeaders { 3 } ) ) ; return $ this ; }
Sets the packet identifier straight from the raw MQTT headers
7,016
private function controlPacketIdentifiers ( WritableContentInterface $ originalRequest ) : bool { if ( $ this -> getPacketIdentifier ( ) !== $ originalRequest -> getPacketIdentifier ( ) ) { $ e = new NonMatchingPacketIdentifiers ( 'Packet identifiers do not match' ) ; $ e -> setOriginPacketIdentifier ( new PacketIdenti...
Checks whether the original request with the current stored packet identifier matches
7,017
public function createOrReverse ( Model \ InStore \ Order $ order , Model \ InStore \ Reversal $ orderReversal = null , HandlerStack $ stack = null ) { try { return $ this -> create ( $ order , $ stack ) ; } catch ( ApiException $ orderException ) { if ( $ orderException -> getErrorResponse ( ) -> getErrorCode ( ) === ...
Helper method to automatically attempt to reverse an order if an error occurs .
7,018
public function makeAuthRequest ( $ returnUrl = null ) { if ( empty ( $ returnUrl ) ) { $ returnUrl = $ this -> getReturnUrl ( ) ; } $ this -> _stateMgr -> set ( 'authRequest' , new AuthRequest ( $ returnUrl ) ) ; $ this -> _stateMgr -> set ( 'authResult' ) ; }
Instruct IdP that this user wishes to be authenticated
7,019
public static function createFileBased ( $ idpUrl , $ cookieName = 'SHIBALIKE' , $ sessionPath = null ) { if ( empty ( $ sessionPath ) ) { $ sessionPath = sys_get_temp_dir ( ) ; } $ session = SessionBuilder :: instance ( ) -> setName ( $ cookieName ) -> setSavePath ( $ sessionPath ) -> build ( ) ; $ stateMgr = new User...
Creates an SP that stores session data in files
7,020
public function findAll ( $ locale ) { $ currencies = $ this -> currencyRepository -> findAll ( ) ; array_walk ( $ currencies , function ( & $ currency ) use ( $ locale ) { $ currency = new Currency ( $ currency , $ locale ) ; } ) ; return $ currencies ; }
Find all currencies .
7,021
public function findById ( $ id , $ locale ) { $ currency = $ this -> currencyRepository -> findById ( $ id ) ; return new Currency ( $ currency , $ locale ) ; }
Finds a currency by id and locale .
7,022
private function logIn ( ) { $ request = xmlrpc_encode_request ( "LogIn" , array ( $ this -> username , $ this -> password , $ this -> lang , $ this -> userAgent ) ) ; $ response = $ this -> generateResponse ( $ request ) ; if ( ( $ response && xmlrpc_is_fault ( $ response ) ) ) { trigger_error ( "xmlrpc: $response[fau...
Log in the OpenSubtitles . org API
7,023
private function searchSubtitles ( $ userToken , $ movieToken , $ fileSize ) { $ request = xmlrpc_encode_request ( "SearchSubtitles" , array ( $ userToken , array ( array ( 'sublanguageid' => $ this -> lang , 'moviehash' => $ movieToken , 'moviebytesize' => $ fileSize ) ) ) ) ; $ response = $ this -> generateResponse (...
Search for a list of subtitles in opensubtitles . org
7,024
public function onCallbackSuccess ( $ order , $ data = null ) { $ paymentId = is_array ( $ data ) ? $ data [ 'paymentId' ] : $ data -> paymentId ; $ payerId = is_array ( $ data ) ? $ data [ 'PayerID' ] : $ data -> PayerID ; $ this -> statusCode = 'failed' ; $ this -> detail = sprintf ( 'Payment failed. Ref: %s' , $ pay...
Called on callback .
7,025
private function setContext ( ) { $ this -> apiContext = new ApiContext ( new OAuthTokenCredential ( Config :: get ( 'services.paypal.client_id' ) , Config :: get ( 'services.paypal.secret' ) ) ) ; if ( ! Config :: get ( 'services.paypal.sandbox' ) ) $ this -> apiContext -> setConfig ( [ 'mode' => 'live' ] ) ; }
Setups contexts for api calls .
7,026
public function getValidAuthResult ( ) { $ authResult = $ this -> _stateMgr -> get ( 'authResult' ) ; if ( $ authResult && $ authResult -> isFresh ( $ this -> _config -> timeout ) ) { return $ authResult ; } return null ; }
Get the User object from the state manager
7,027
public function reset ( ) { $ this -> values = array ( ) ; $ this -> xlabel = null ; $ this -> ylabel = null ; $ this -> labels = array ( ) ; $ this -> titles = array ( ) ; $ this -> xrange = null ; $ this -> yrange = null ; $ this -> title = null ; }
Reset all the values
7,028
protected function sendInit ( ) { $ this -> sendCommand ( 'set grid' ) ; if ( $ this -> title ) { $ this -> sendCommand ( 'set title "' . $ this -> title . '"' ) ; } if ( $ this -> xlabel ) { $ this -> sendCommand ( 'set xlabel "' . $ this -> xlabel . '"' ) ; } if ( $ this -> timeFormat ) { $ this -> sendCommand ( 'set...
Create the pipe
7,029
public function plot ( $ replot = false ) { if ( $ replot ) { $ this -> sendCommand ( 'replot' ) ; } else { $ this -> sendCommand ( 'plot ' . $ this -> getUsings ( ) ) ; } $ this -> plotted = true ; $ this -> sendData ( ) ; }
Runs the plot to the given pipe
7,030
public function addLabel ( $ x , $ y , $ text ) { $ this -> labels [ ] = array ( $ x , $ y , $ text ) ; return $ this ; }
Add a label text
7,031
protected function getUsings ( ) { $ usings = array ( ) ; for ( $ i = 0 ; $ i < count ( $ this -> values ) ; $ i ++ ) { $ using = '"-" using 1:2 with ' . $ this -> mode ; if ( isset ( $ this -> titles [ $ i ] ) ) { $ using .= ' title "' . $ this -> titles [ $ i ] . '"' ; } $ usings [ ] = $ using ; } return implode ( ',...
Gets the using line
7,032
protected function sendData ( ) { foreach ( $ this -> values as $ index => $ data ) { foreach ( $ data as $ xy ) { list ( $ x , $ y ) = $ xy ; $ this -> sendCommand ( $ x . ' ' . $ y ) ; } $ this -> sendCommand ( 'e' ) ; } }
Sends all the command to the given pipe to give it the current data
7,033
protected function openPipe ( ) { $ descriptorspec = array ( 0 => array ( 'pipe' , 'r' ) , 1 => array ( 'pipe' , 'w' ) , 2 => array ( 'pipe' , 'r' ) ) ; $ this -> process = proc_open ( 'gnuplot' , $ descriptorspec , $ pipes ) ; if ( ! is_resource ( $ this -> process ) ) { throw new \ Exception ( 'Unable to run GnuPlot'...
Open the pipe
7,034
public function getAction ( Request $ request , $ id ) { $ locale = $ this -> getProductLocaleManager ( ) -> retrieveLocale ( $ this -> getUser ( ) , $ request -> get ( 'locale' ) ) ; $ view = $ this -> responseGetById ( $ id , function ( $ id ) use ( $ locale ) { $ product = $ this -> getManager ( ) -> findByIdAndLoca...
Retrieves and shows a product with the given ID .
7,035
public function cgetAction ( Request $ request ) { $ filter = $ this -> getManager ( ) -> getFilters ( $ request ) ; $ locale = $ this -> getProductLocaleManager ( ) -> retrieveLocale ( $ this -> getUser ( ) , $ request -> get ( 'locale' ) ) ; if ( $ request -> get ( 'flat' ) == 'true' ) { $ filterFieldDescriptors = $ ...
Returns a list of products .
7,036
protected function flatResponse ( Request $ request , $ filter , $ filterFieldDescriptors , $ fieldDescriptors , $ entityName ) { $ listBuilder = $ this -> getListBuilder ( $ entityName , $ fieldDescriptors ) ; foreach ( $ filter as $ key => $ value ) { if ( is_array ( $ value ) ) { $ listBuilder -> in ( $ filterFieldD...
Processes the request for a flat response .
7,037
public function putAction ( Request $ request , $ id ) { $ locale = $ this -> getProductLocaleManager ( ) -> retrieveLocale ( $ this -> getUser ( ) , $ request -> get ( 'locale' ) ) ; try { $ product = $ this -> getManager ( ) -> save ( $ request -> request -> all ( ) , $ locale , $ this -> getUser ( ) -> getId ( ) , $...
Change a product entry by the given product id .
7,038
public function deleteAction ( Request $ request , $ id ) { $ locale = $ this -> getProductLocaleManager ( ) -> retrieveLocale ( $ this -> getUser ( ) , $ request -> get ( 'locale' ) ) ; $ delete = function ( $ id ) use ( $ locale ) { try { $ this -> getManager ( ) -> delete ( $ id , $ this -> getUser ( ) -> getId ( ) ...
Delete a product with the given id .
7,039
public function patchAction ( Request $ request , $ id ) { $ locale = $ this -> getProductLocaleManager ( ) -> retrieveLocale ( $ this -> getUser ( ) , $ request -> get ( 'locale' ) ) ; try { $ product = $ this -> getManager ( ) -> partialUpdate ( $ request -> request -> all ( ) , $ locale , $ this -> getUser ( ) -> ge...
Make a partial update of a product .
7,040
public function getSupplier ( ) { $ values = null ; $ supplier = $ this -> entity -> getSupplier ( ) ; if ( $ supplier !== null ) { $ values = [ 'id' => $ supplier -> getId ( ) , 'name' => $ supplier -> getName ( ) , ] ; } return $ values ; }
Returns the supplier of the product .
7,041
public function getParent ( ) { $ parent = $ this -> entity -> getParent ( ) ; if ( ! $ parent ) { return null ; } return $ this -> productFactory -> createApiEntity ( $ parent , $ this -> locale ) ; }
Returns the parent of the product .
7,042
public function setParent ( Product $ parent = null ) { if ( $ parent != null ) { $ this -> entity -> setParent ( $ parent -> getEntity ( ) ) ; } else { $ this -> entity -> setParent ( null ) ; } }
Sets the parent of the product .
7,043
public function getType ( ) { if ( $ this -> entity -> getType ( ) ) { return new Type ( $ this -> entity -> getType ( ) , $ this -> locale ) ; } return null ; }
Returns the type of the product .
7,044
public function getDeliveryStatus ( ) { $ status = $ this -> entity -> getDeliveryStatus ( ) ; if ( $ status !== null ) { return new DeliveryStatus ( $ status , $ this -> locale ) ; } return null ; }
Returns the delivery status of the product .
7,045
public function getOrderUnit ( ) { $ unit = $ this -> entity -> getOrderUnit ( ) ; if ( ! is_null ( $ unit ) ) { return new Unit ( $ unit , $ this -> locale ) ; } return null ; }
Returns the orderUnit of the product .
7,046
public function getContentUnit ( ) { $ unit = $ this -> entity -> getContentUnit ( ) ; if ( ! is_null ( $ unit ) ) { return new Unit ( $ unit , $ this -> locale ) ; } return null ; }
Returns the contentUnit of the product .
7,047
public function getTaxClass ( ) { $ taxClass = $ this -> entity -> getTaxClass ( ) ; if ( $ taxClass ) { return new TaxClass ( $ this -> entity -> getTaxClass ( ) , $ this -> locale ) ; } return null ; }
Returns the tax class of the product .
7,048
public function getAttributeSet ( ) { $ attributeSet = $ this -> entity -> getAttributeSet ( ) ; if ( $ attributeSet ) { return new AttributeSet ( $ attributeSet , $ this -> locale ) ; } return null ; }
Returns the attribute set of the product .
7,049
public function getPrices ( ) { $ priceEntities = $ this -> entity -> getPrices ( ) ; $ prices = [ ] ; foreach ( $ priceEntities as $ priceEntity ) { $ prices [ ] = new ProductPrice ( $ priceEntity , $ this -> locale ) ; } return $ prices ; }
Returns the prices for the product .
7,050
public function getScalePriceForCurrency ( $ currency = 'EUR' ) { $ scalePrice = null ; $ prices = $ this -> entity -> getPrices ( ) ; if ( $ prices ) { foreach ( $ prices as $ price ) { if ( $ price -> getCurrency ( ) -> getCode ( ) == $ currency ) { $ scalePrice [ ] = $ price ; } } } return $ scalePrice ; }
Returns the scale price for a certain currency .
7,051
public function getFormattedSpecialPriceForCurrency ( $ currency = 'EUR' , $ formatterLocale = null ) { $ price = $ this -> getSpecialPriceForCurrency ( $ currency ) ; if ( $ price ) { return $ this -> getFormattedPrice ( $ price -> getPrice ( ) , $ currency , $ formatterLocale ) ; } return '' ; }
Returns the formatted special price for the product by a given currency and locale .
7,052
public function getSpecialPriceForCurrency ( $ currency = 'EUR' ) { $ specialPrices = $ this -> entity -> getSpecialPrices ( ) ; if ( $ specialPrices ) { foreach ( $ specialPrices as $ specialPriceEntity ) { if ( $ specialPriceEntity -> getCurrency ( ) -> getCode ( ) == $ currency ) { $ startDate = $ specialPriceEntity...
Returns the special price for a certain currency .
7,053
public function getFormattedBasePriceForCurrency ( $ currency = 'EUR' ) { $ price = $ this -> getBasePriceForCurrency ( $ currency ) ; if ( $ price ) { return $ this -> getFormattedPrice ( $ price -> getPrice ( ) , $ currency , $ this -> locale ) ; } return '' ; }
Returns the formatted base price for the product by a given currency and locale .
7,054
public function getBasePriceForCurrency ( $ currency = 'EUR' ) { $ prices = $ this -> entity -> getPrices ( ) ; if ( $ prices ) { foreach ( $ prices as $ price ) { if ( $ price -> getCurrency ( ) -> getCode ( ) == $ currency && $ price -> getMinimumQuantity ( ) == 0 ) { return new ProductPrice ( $ price , $ this -> loc...
Returns the base price for the product by a given currency .
7,055
public function getAttributes ( ) { $ attributeEntities = $ this -> entity -> getProductAttributes ( ) ; $ attributes = [ ] ; foreach ( $ attributeEntities as $ attributesEntity ) { $ attributes [ ] = new ProductAttribute ( $ attributesEntity , $ this -> locale , $ this -> productLocaleManager -> getFallbackLocale ( ) ...
Returns the attributes for the product .
7,056
public function getCategories ( ) { $ categoryEntities = $ this -> entity -> getCategories ( ) ; $ categories = [ ] ; if ( $ categoryEntities ) { foreach ( $ categoryEntities as $ categoryEntity ) { $ categories [ ] = new Category ( $ categoryEntity , $ this -> locale ) ; } } return $ categories ; }
Returns the categories for the product .
7,057
public function getMedia ( ) { if ( $ this -> media ) { return $ this -> media ; } $ mediaCollection = [ ] ; $ media = $ this -> entity -> getMedia ( ) ; if ( ! $ media ) { return $ mediaCollection ; } foreach ( $ media as $ medium ) { $ mediaCollection [ ] = new Media ( $ medium , $ this -> locale ) ; } return $ media...
Returns the media for the product .
7,058
private function getMediaByType ( $ type ) { $ collection = [ ] ; $ media = $ this -> getMedia ( ) ; if ( ! $ media ) { return $ collection ; } foreach ( $ media as $ asset ) { if ( $ asset -> isTypeOf ( $ type ) ) { $ collection [ ] = $ asset ; } } return $ collection ; }
Returns a media array by a given type for the product .
7,059
public function getSpecialPrices ( ) { $ specialPrices = $ this -> entity -> getSpecialPrices ( ) ; $ specialPricesList = [ ] ; foreach ( $ specialPrices as $ specialPrice ) { $ specialPricesList [ ] = new SpecialPrice ( $ specialPrice , $ this -> locale ) ; } return $ specialPricesList ; }
Returns the special prices for the product .
7,060
public function downloadSubtitle ( $ url , $ originalFile ) { $ subtitleFile = preg_replace ( "/\\.[^.\\s]{3,4}$/" , "" , $ originalFile ) . '.srt' ; $ subtitleContent = gzdecode ( file_get_contents ( $ url ) ) ; file_put_contents ( $ subtitleFile , $ subtitleContent ) ; }
Download subtitle and put it in the same folder than the video with the same name + srt
7,061
public function getUrl ( ) { $ data = $ this -> getRawData ( ) ; if ( $ data && ! filter_var ( $ data , FILTER_VALIDATE_URL ) !== false ) { if ( ! is_string ( $ data ) ) { $ data = \ GuzzleHttp \ json_encode ( $ data ) ; } $ identifier = Auth :: guest ( ) ? time ( ) : Auth :: id ( ) ; $ file = $ this -> dataFolder . DI...
Saves a temporary json file and generates public url that is sent to PDF Generator service
7,062
public function findAll ( $ locale ) { $ statuses = $ this -> deliveryStatusRepository -> findAllByLocale ( $ locale ) ; array_walk ( $ statuses , function ( & $ status ) use ( $ locale ) { $ status = new DeliveryStatus ( $ status , $ locale ) ; } ) ; return $ statuses ; }
Returns all delivery statuses by given locale .
7,063
public function retrieveTranslationByIdAndLocale ( $ deliveryStatusId , $ locale ) { $ deliveryStatus = $ this -> deliveryStatusRepository -> find ( $ deliveryStatusId ) ; if ( ! $ deliveryStatus || $ deliveryStatus -> getTranslations ( ) -> count ( ) < 1 ) { return null ; } $ deliveryStatusTranslation = $ deliveryStat...
Returns DeliveryStatusTranslation by given DeliveryStatus - id and locale .
7,064
public function createProductAttribute ( Attribute $ attribute , ProductInterface $ product , AttributeValue $ attributeValue ) { $ productAttribute = $ this -> productAttributeRepository -> createNew ( ) ; $ productAttribute -> setAttribute ( $ attribute ) ; $ productAttribute -> setProduct ( $ product ) ; $ productAt...
Creates a new ProductAttribute relation .
7,065
public function createAttributeValue ( Attribute $ attribute , $ value , $ locale ) { $ attributeValue = $ this -> attributeValueRepository -> createNew ( ) ; $ attributeValue -> setAttribute ( $ attribute ) ; $ this -> entityManager -> persist ( $ attributeValue ) ; $ attribute -> addValue ( $ attributeValue ) ; $ thi...
Creates a new attribute value and its translation in the specified locale .
7,066
public function setOrCreateAttributeValueTranslation ( AttributeValue $ attributeValue , $ value , $ locale ) { $ attributeValueTranslation = null ; foreach ( $ attributeValue -> getTranslations ( ) as $ translation ) { if ( $ translation -> getLocale ( ) === $ locale ) { $ attributeValueTranslation = $ translation ; }...
Checks if AttributeValue already contains a translation in given locale or creates a new one .
7,067
public function removeAttributeValueTranslation ( AttributeValue $ attributeValue , $ locale ) { $ attributeValueTranslation = $ this -> retrieveAttributeValueTranslationByLocale ( $ attributeValue , $ locale ) ; if ( $ attributeValueTranslation ) { $ attributeValue -> removeTranslation ( $ attributeValueTranslation ) ...
Removes attribute value translation in given locale from given attribute .
7,068
public function removeAllAttributeValueTranslations ( AttributeValue $ attributeValue ) { foreach ( $ attributeValue -> getTranslations ( ) as $ attributeValueTranslation ) { $ attributeValue -> removeTranslation ( $ attributeValueTranslation ) ; $ this -> entityManager -> remove ( $ attributeValueTranslation ) ; } }
Removes all attribute value translations from given attribute .
7,069
public function updateOrCreateProductAttributeForProduct ( ProductInterface $ product , Attribute $ attribute , array $ attributeData , $ locale ) { $ existingProductAttribute = $ this -> retrieveProductAttributeByAttribute ( $ product , $ attribute ) ; if ( $ existingProductAttribute ) { $ this -> setOrCreateAttribute...
Updates or creates a the product attribute relation for the given product .
7,070
public function retrieveProductAttributeByAttribute ( ProductInterface $ product , Attribute $ attribute ) { foreach ( $ product -> getProductAttributes ( ) as $ productAttribute ) { if ( $ productAttribute -> getAttribute ( ) -> getId ( ) === $ attribute -> getId ( ) ) { return $ productAttribute ; } } return null ; }
Searches products product - attributes for given attribute .
7,071
private function retrieveAttributeValueTranslationByLocale ( AttributeValue $ attributeValue , $ locale ) { foreach ( $ attributeValue -> getTranslations ( ) as $ attributeValueTranslation ) { if ( $ attributeValueTranslation -> getLocale ( ) === $ locale ) { return $ attributeValueTranslation ; } } return null ; }
Returns the translation in given locale for the given AttributeValue .
7,072
public function findByAbbrevation ( $ abbrevation , $ returnAsEntity = false ) { try { $ qb = $ this -> createQueryBuilder ( 'unit' ) -> select ( 'partial unit.{id}' ) -> join ( 'unit.mappings' , 'mappings' , 'WITH' , 'mappings.name = :abbrevation' ) -> setParameter ( 'abbrevation' , $ abbrevation ) ; if ( $ returnAsEn...
Find a unit by it s abbrevation .
7,073
public function findAllByLocale ( $ locale ) { try { $ qb = $ this -> getUnitQuery ( $ locale ) -> orderBy ( 'unitTranslations.name' , 'ASC' ) ; return $ qb -> getQuery ( ) -> getResult ( ) ; } catch ( NoResultException $ exc ) { return null ; } }
Returns the units with the given locale .
7,074
public function findByCode ( $ code ) { try { $ qb = $ this -> createQueryBuilder ( 'currency' ) -> andWhere ( 'currency.code = :currencyCode' ) -> setParameter ( 'currencyCode' , $ code ) ; return $ qb -> getQuery ( ) -> getSingleResult ( ) ; } catch ( NoResultException $ exc ) { return null ; } }
Find a currency by it s code .
7,075
public function removeProduct ( \ Sulu \ Bundle \ ProductBundle \ Entity \ Product $ products ) { $ this -> products -> removeElement ( $ products ) ; }
Remove products .
7,076
private function throwConnectException ( ) : self { switch ( $ this -> connectReturnCode ) { case 1 : throw new UnacceptableProtocolVersion ( 'The Server does not support the level of the MQTT protocol requested by the Client' ) ; case 2 : throw new IdentifierRejected ( 'The Client identifier is correct UTF-8 but not a...
Will throw an exception in case there is something bad with the connection
7,077
protected function initFieldDescriptors ( $ locale ) { $ this -> fieldDescriptors = [ ] ; $ mediaJoin = [ self :: $ mediaEntityName => new DoctrineJoinDescriptor ( self :: $ mediaEntityName , $ this -> productEntityName . '.media' , null , DoctrineJoinDescriptor :: JOIN_METHOD_INNER ) , ] ; $ fileVersionJoin = array_me...
Initializes field descriptors for product media .
7,078
final public function createFixedHeader ( int $ variableHeaderLength ) : string { $ this -> logger -> debug ( 'Creating fixed header with values' , [ 'controlPacketValue' => self :: getControlPacketValue ( ) , 'specialFlags' => $ this -> specialFlags , 'variableHeaderLength' => $ variableHeaderLength , 'composed' => de...
Returns the fixed header part needed for all methods
7,079
final public function createSendableMessage ( ) : string { $ variableHeader = $ this -> createVariableHeader ( ) ; $ this -> logger -> debug ( 'Created variable header' , [ 'variableHeader' => base64_encode ( $ variableHeader ) ] ) ; $ payload = $ this -> createPayload ( ) ; $ this -> logger -> debug ( 'Created payload...
Creates the entire message
7,080
final public function createUTF8String ( string $ nonFormattedString ) : string { $ returnString = '' ; if ( $ nonFormattedString !== '' ) { $ returnString = Utilities :: convertNumberToBinaryString ( strlen ( $ nonFormattedString ) ) . $ nonFormattedString ; } return $ returnString ; }
Creates a UTF8 big - endian representation of the given string
7,081
public function expectAnswer ( string $ brokerBitStream , ClientInterface $ client ) : ReadableContentInterface { $ this -> logger -> info ( 'String of incoming data confirmed, returning new object' , [ 'callee' => get_class ( $ this ) ] ) ; $ eventManager = new EventManager ( $ this -> logger ) ; return $ eventManager...
Will return an object of the type the broker has returned to us
7,082
public function setAttributeSet ( \ Sulu \ Bundle \ ProductBundle \ Entity \ AttributeSet $ template ) { $ this -> attributeSet = $ template ; return $ this ; }
Set template .
7,083
private function checkControlPacketValue ( int $ controlPacketValue ) : bool { if ( static :: CONTROL_PACKET_VALUE !== $ controlPacketValue ) { throw new InvalidResponseType ( sprintf ( 'Value of received value does not correspond to response (Expected: %d, Actual: %d)' , static :: CONTROL_PACKET_VALUE , $ controlPacke...
Checks whether the control packet corresponds to this object
7,084
private function calculateSizeOfRemainingLengthField ( int $ size ) : int { $ blockSize = $ iterations = 0 ; while ( $ size >= $ blockSize ) { $ iterations ++ ; $ blockSize = 128 ** $ iterations ; } $ this -> sizeOfRemainingLengthField = $ iterations ; return $ iterations ; }
Sets the offset of the remaining length field
7,085
public function setAttributeValue ( \ Sulu \ Bundle \ ProductBundle \ Entity \ AttributeValue $ attributeValue ) { $ this -> attributeValue = $ attributeValue ; return $ this ; }
Set attributeValue .
7,086
public static function callProtectedMethod ( $ object , $ method , ... $ args ) { $ refObject = new \ ReflectionObject ( $ object ) ; $ refProp = $ refObject -> getMethod ( $ method ) ; $ refProp -> setAccessible ( true ) ; return $ refProp -> invokeArgs ( $ object , $ args ) ; }
Helper to allow calling protected methods with variable arguments
7,087
public static function getProtectedProperty ( $ object , $ property ) { $ refObject = new \ ReflectionObject ( $ object ) ; $ refProp = $ refObject -> getProperty ( $ property ) ; $ refProp -> setAccessible ( true ) ; return $ refProp -> getValue ( $ object ) ; }
Helper to allow accessing protected properties without an accessor
7,088
public static function setProtectedProperty ( $ object , $ property , $ value ) { $ refObject = new \ ReflectionObject ( $ object ) ; $ refProp = $ refObject -> getProperty ( $ property ) ; $ refProp -> setAccessible ( true ) ; $ refProp -> setValue ( $ object , $ value ) ; return $ object ; }
Helper to allow setting protected properties returns the passed object
7,089
private function initTargets ( $ installDir , $ filename ) { if ( $ installDir === false ) { $ installDir = getcwd ( ) ; } $ this -> installPath = rtrim ( $ installDir , '/' ) . '/' . $ filename ; if ( ! is_writable ( $ installDir ) ) { throw new RuntimeException ( 'The installation directory "' . $ installDir . '" is ...
Initialization methods to set the required filenames and base url
7,090
private function install ( $ version ) { $ retries = 3 ; $ infoMsg = 'Downloading...' ; $ infoType = 'info' ; $ success = false ; while ( $ retries -- ) { try { if ( ! $ this -> quiet ) { out ( $ infoMsg , $ infoType ) ; $ infoMsg = 'Retrying...' ; $ infoType = 'error' ; } $ releaseInfo = $ this -> getReleaseInfo ( $ v...
The main install function
7,091
private function downloadTemporaryFile ( $ url , $ target ) { try { if ( ( $ fh = @ fopen ( $ target , 'w' ) ) === false ) { throw new RuntimeException ( sprintf ( 'Could not create file "%s": %s' , $ target , @ error_get_last ( ) [ 'message' ] ) ) ; } if ( ( @ fwrite ( $ fh , $ this -> httpClient -> get ( $ url , 'app...
A wrapper around the methods needed to download and save the phar
7,092
private function verifyAndSave ( ) { $ this -> pharValidator -> assertPharValid ( $ this -> tmpPharPath ) ; if ( ! @ rename ( $ this -> tmpPharPath , $ this -> target ) ) { throw new RuntimeException ( sprintf ( 'Could not write to file "%s": %s' , $ this -> target , @ error_get_last ( ) [ 'message' ] ) ) ; } if ( ! @ ...
Verifies the downloaded file and saves it to the target location
7,093
private function cleanUp ( ) { if ( $ this -> quiet ) { $ errors = explode ( PHP_EOL , ob_get_clean ( ) ) ; $ shown = [ ] ; foreach ( $ errors as $ error ) { if ( $ error && ! in_array ( $ error , $ shown ) ) { out ( $ error , 'error' ) ; $ shown [ ] = $ error ; } } } if ( file_exists ( $ this -> tmpPharPath ) ) { @ un...
Cleans up resources at the end of a failed installation
7,094
public function setDeliveryStatus ( \ Sulu \ Bundle \ ProductBundle \ Entity \ DeliveryStatus $ deliveryStatus ) { $ this -> deliveryStatus = $ deliveryStatus ; return $ this ; }
Set deliveryStatus .
7,095
public function removeAttribute ( \ Sulu \ Bundle \ ProductBundle \ Entity \ Attribute $ attributes ) { $ this -> attributes -> removeElement ( $ attributes ) ; }
Remove attributes .
7,096
public function retrieveLocale ( UserInterface $ user = null , $ requestLocale = null ) { $ checkedLocale = null ; if ( $ requestLocale && is_string ( $ requestLocale ) ) { $ checkedLocale = $ this -> checkLocale ( $ requestLocale ) ; } if ( ! $ checkedLocale && $ user && $ user -> getLocale ( ) ) { $ checkedLocale = $...
Function returns the locale that should be used by default . If request - locale is set then use this one . Else If users locale matches any of the given locales that one is taken as default . If locale does not match exactly the users language is compared as well when its provided . If there are no matches at all the ...
7,097
protected function checkLocale ( $ locale ) { $ languageFound = null ; $ language = strstr ( $ locale , '_' , true ) ; foreach ( $ this -> configuration [ 'locales' ] as $ availableLocale ) { if ( $ availableLocale === $ locale ) { return $ availableLocale ; } if ( $ language == $ availableLocale ) { $ languageFound = ...
Check if given locale is available in the configured locales .
7,098
public function findAllByLocale ( $ locale ) { try { $ qb = $ this -> getStatusQuery ( $ locale ) ; return $ qb -> getQuery ( ) -> getResult ( ) ; } catch ( NoResultException $ exc ) { return null ; } }
Returns the statuses with the given locale .
7,099
public function onCheckout ( $ cart ) { if ( ! isset ( $ this -> creditCard ) ) throw new CheckoutException ( 'Credit Card is not set.' , 0 ) ; if ( ! in_array ( $ this -> creditCard -> getType ( ) , $ this -> validTypes ) ) throw new CheckoutException ( 'Credit Card is not supported.' , 1 ) ; if ( $ this -> getPattern...
Called on cart checkout .