idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
15,600
protected function mapResponse ( $ success , array $ response ) { return ( new Response ( ) ) -> setRaw ( $ response ) -> map ( [ 'success' => $ success , 'message' => $ success ? 'Message sent' : $ response [ 'message' ] , ] ) ; }
Map the raw response to our response object .
15,601
public function setConfig ( array $ config ) { try { $ this -> config = $ this -> getConfigResolver ( ) -> resolve ( $ config ) ; } catch ( ExceptionInterface $ e ) { throw new InvalidArgumentException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } }
Configures the api .
15,602
public function createPaymentForm ( array $ data ) { $ this -> ensureApiIsConfigured ( ) ; try { $ data = $ this -> getRequestOptionsResolver ( ) -> resolve ( $ data ) ; } catch ( ExceptionInterface $ e ) { throw new InvalidArgumentException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } $ fields = [ 'TPE' =>...
Creates the request form .
15,603
public function checkPaymentResponse ( array $ data ) { if ( ! isset ( $ data [ 'MAC' ] ) ) { return false ; } $ data = array_replace ( [ 'date' => null , 'montant' => null , 'reference' => null , 'texte-libre' => null , 'code-retour' => null , 'cvx' => null , 'vld' => null , 'brand' => null , 'status3ds' => null , 'nu...
Checks the payment response integrity .
15,604
public function getMacKey ( ) { $ key = $ this -> config [ 'key' ] ; $ hexStrKey = substr ( $ key , 0 , 38 ) ; $ hexFinal = "" . substr ( $ key , 38 , 2 ) . "00" ; $ cca0 = ord ( $ hexFinal ) ; if ( $ cca0 > 70 && $ cca0 < 97 ) { $ hexStrKey .= chr ( $ cca0 - 23 ) . substr ( $ hexFinal , 1 , 1 ) ; } else { if ( substr ...
Returns the key formatted for mac generation .
15,605
private function htmlEncode ( $ data ) { if ( empty ( $ data ) ) { return null ; } $ safeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890._-" ; $ result = "" ; for ( $ i = 0 ; $ i < strlen ( $ data ) ; $ i ++ ) { if ( strstr ( $ safeChars , $ data [ $ i ] ) ) { $ result .= $ data [ $ i ] ; } else...
Encode html string .
15,606
public static function create ( ExpressionNode $ array , ExpressionNode $ key ) { $ node = new static ( ) ; $ node -> addChild ( $ array , 'array' ) ; $ node -> addChild ( Token :: openBracket ( ) ) ; $ node -> addChild ( $ key , 'key' ) ; $ node -> addChild ( Token :: closeBracket ( ) ) ; return $ node ; }
Creates a new array lookup .
15,607
public function getKey ( $ index = 0 ) { $ keys = $ this -> getKeys ( ) ; if ( ! is_integer ( $ index ) ) { throw new \ InvalidArgumentException ( ) ; } if ( $ index < 0 || $ index >= count ( $ keys ) ) { throw new \ OutOfBoundsException ( ) ; } return $ keys [ $ index ] ; }
Returns a specific key in the lookup .
15,608
public function addLocales ( ConfigureLocales $ event ) { foreach ( new DirectoryIterator ( __DIR__ . '/../../locale' ) as $ file ) { if ( $ file -> isFile ( ) && in_array ( $ file -> getExtension ( ) , [ 'yml' , 'yaml' ] ) ) { $ event -> locales -> addTranslations ( $ file -> getBasename ( '.' . $ file -> getExtension...
Provides i18n files .
15,609
public function checkModuleValidity ( UploadedFile $ file , ExecutionContextInterface $ context ) { $ modulePath = $ this -> unzipModule ( $ file ) ; if ( $ modulePath !== false ) { try { $ moduleFiles = $ this -> getDirContents ( $ modulePath ) ; if ( \ count ( $ moduleFiles [ 'directories' ] ) !== 1 ) { throw new Exc...
Check module validity
15,610
protected function unzipModule ( UploadedFile $ file ) { $ extractPath = false ; $ zip = new ZipArchiver ( true ) ; if ( ! $ zip -> open ( $ file -> getRealPath ( ) ) ) { throw new \ Exception ( "unable to open zipfile" ) ; } $ extractPath = $ this -> tempdir ( ) ; if ( $ extractPath !== false ) { if ( $ zip -> extract...
Unzip a module file .
15,611
protected function tempdir ( ) { $ tempfile = tempnam ( sys_get_temp_dir ( ) , '' ) ; if ( file_exists ( $ tempfile ) ) { unlink ( $ tempfile ) ; } mkdir ( $ tempfile ) ; if ( is_dir ( $ tempfile ) ) { return $ tempfile ; } return false ; }
create a unique directory .
15,612
public static function create ( $ boolean = FALSE ) { $ is_upper = FormatterFactory :: getDefaultFormatter ( ) -> getConfig ( 'boolean_null_upper' ) ; $ node = new FalseNode ( ) ; $ node -> addChild ( NameNode :: create ( $ is_upper ? 'FALSE' : 'false' ) , 'constantName' ) ; return $ node ; }
Creates a new FalseNode .
15,613
public function appendMethodCall ( $ method_name ) { $ method_call = ObjectMethodCallNode :: create ( clone $ this , $ method_name ) ; $ this -> replaceWith ( $ method_call ) ; return $ method_call ; }
Allows you to append a method call to this one building a chain of method calls .
15,614
public function countAllContents ( $ contentVisibility = true ) { $ children = FolderQuery :: findAllChild ( $ this -> getId ( ) ) ; array_push ( $ children , $ this ) ; $ query = ContentQuery :: create ( ) -> filterByFolder ( new ObjectCollection ( $ children ) , Criteria :: IN ) ; if ( $ contentVisibility !== '*' ) {...
count all products for current category and sub categories
15,615
public function getRoot ( $ folderId ) { $ folder = FolderQuery :: create ( ) -> findPk ( $ folderId ) ; if ( 0 !== $ folder -> getParent ( ) ) { $ parentFolder = FolderQuery :: create ( ) -> findPk ( $ folder -> getParent ( ) ) ; if ( null !== $ parentFolder ) { $ folderId = $ this -> getRoot ( $ parentFolder -> getId...
Get the root folder
15,616
public function runCommand ( Command $ command , array $ parameters = [ ] , OutputInterface $ output = null ) { $ parameters [ 'command' ] = $ command -> getName ( ) ; $ input = new ArrayInput ( $ parameters ) ; if ( $ output === null ) { $ output = new NullOutput ( ) ; } $ command -> setApplication ( new SymfonyConsol...
Run a Propel command .
15,617
public function buildPropelConfig ( ) { $ propelConfigCache = new ConfigCache ( $ this -> getPropelConfigFile ( ) , $ this -> debug ) ; if ( $ propelConfigCache -> isFresh ( ) ) { return ; } $ configService = new DatabaseConfigurationSource ( Yaml :: parse ( file_get_contents ( $ this -> getTheliaDatabaseConfigFile ( )...
Generate the Propel configuration file .
15,618
public function buildPropelInitFile ( ) { $ propelInitCache = new ConfigCache ( $ this -> getPropelInitFile ( ) , $ this -> debug ) ; if ( $ propelInitCache -> isFresh ( ) ) { return ; } $ this -> runCommand ( new ConfigConvertCommand ( ) , [ '--config-dir' => $ this -> getPropelConfigDir ( ) , '--output-dir' => $ this...
Generate the Propel initialization file .
15,619
public function buildPropelModels ( ) { $ fs = new Filesystem ( ) ; if ( $ fs -> exists ( $ this -> getPropelModelDir ( ) . 'hash' ) && file_get_contents ( $ this -> getPropelCacheDir ( ) . 'hash' ) === file_get_contents ( $ this -> getPropelModelDir ( ) . 'hash' ) ) { return ; } $ fs -> remove ( $ this -> getPropelMod...
Generate the base Propel models .
15,620
public function registerPropelModelLoader ( ) { $ loader = new ClassLoader ( ) ; $ loader -> addPrefix ( '' , $ this -> getPropelModelDir ( ) ) ; $ loader -> register ( true ) ; }
Register a class loader to load the generated Propel models .
15,621
public function init ( $ force = false ) { $ flockFactory = new Factory ( new FlockStore ( ) ) ; $ lock = $ flockFactory -> createLock ( 'propel-cache-generation' ) ; $ lock -> acquire ( true ) ; try { if ( $ force ) { ( new Filesystem ( ) ) -> remove ( $ this -> getPropelCacheDir ( ) ) ; } if ( ! file_exists ( $ this ...
Initialize the Propel environment and connection .
15,622
protected function addLoaderFile ( string $ file , string $ locale = null ) : void { if ( $ this -> loader === null ) { $ builder = $ this -> getContainerBuilder ( ) ; $ loader = $ builder -> getByType ( LoaderFactory :: class ) ; $ this -> loader = $ builder -> getDefinition ( $ loader ) ; } $ this -> loader -> addSet...
Prida soubor do loaderu
15,623
public function setLoad ( $ libraries ) { $ load = false ; $ product = false ; foreach ( $ libraries as $ name => $ version ) { if ( strpos ( $ version , 'dev' ) !== false ) { $ load = $ version ; $ product = $ name ; break ; } if ( version_compare ( $ load , $ version ) === - 1 ) { $ load = $ version ; $ product = $ n...
Sets the product and version of library to load .
15,624
public function setPath ( ) { $ found = $ this -> getLoad ( ) ; $ path = false ; if ( ! empty ( $ found -> product ) ) { if ( ! is_file ( $ path = trailingslashit ( WPMU_PLUGIN_DIR ) . $ found -> product ) ) { if ( ! is_file ( $ path = trailingslashit ( WP_PLUGIN_DIR ) . $ found -> product ) ) { $ path = get_template_d...
Sets the path class property .
15,625
public function load ( $ loader ) { if ( ! empty ( $ this -> configs [ 'libraryDir' ] ) ) { $ library = $ this -> configs [ 'libraryDir' ] . 'src/Library' ; if ( did_action ( 'Boldgrid\Library\Library\Start' ) === 0 ) { do_action ( 'Boldgrid\Library\Library\Start' , $ library ) ; if ( is_dir ( $ library ) ) { $ loader ...
Adds the Library paths to the autoloader .
15,626
public function setDefault ( ) : void { $ repo = $ this -> getRepository ( ) ; $ locales = $ repo -> findAll ( ) ; foreach ( $ locales as $ locale ) { $ locale -> default = false ; $ repo -> persist ( $ locale ) ; } $ this -> default = true ; $ repo -> persist ( $ this ) ; $ repo -> flush ( ) ; }
Nastavi na vychozi
15,627
public function getOriginOfPageByPageIdAction ( ) { $ data = array ( ) ; $ tool = $ this -> getServiceLocator ( ) -> get ( 'MelisCmsPage' ) ; $ data = $ tool -> getOriginOfPage ( ) -> toArray ( ) ; return $ data ; }
Return the origin of the page by id
15,628
public function process ( \ Symfony \ Component \ DependencyInjection \ ContainerBuilder $ container ) { if ( ! $ container -> hasDefinition ( "thelia.admin.resources" ) ) { return ; } $ adminResources = $ container -> getDefinition ( "thelia.admin.resources" ) ; $ adminResources -> addMethodCall ( "addModuleResources"...
Allow module to add resources in AdminResources Service
15,629
public function checkMandatoryColumns ( array $ data ) { $ diff = array_diff ( $ this -> mandatoryColumns , array_keys ( $ data ) ) ; if ( \ count ( $ diff ) > 0 ) { throw new \ UnexpectedValueException ( Translator :: getInstance ( ) -> trans ( 'The following columns are missing: %columns' , [ '%columns' => implode ( ...
Check mandatory columns
15,630
public function applyOrderAndAliases ( array $ data ) { if ( $ this -> orderAndAliases === null ) { return $ data ; } $ processedData = [ ] ; foreach ( $ this -> orderAndAliases as $ key => $ value ) { if ( \ is_integer ( $ key ) ) { $ fieldName = $ value ; $ fieldAlias = $ value ; } else { $ fieldName = $ key ; $ fiel...
Apply order and aliases on data
15,631
public function beforeSerialize ( array $ data ) { foreach ( $ data as $ idx => & $ value ) { if ( $ value instanceof \ DateTime ) { $ value = $ value -> format ( 'Y-m-d H:i:s' ) ; } } return $ data ; }
Process data before serialization
15,632
private static function doFilter ( $ action , $ class ) { $ reflection = new \ ReflectionClass ( $ class ) ; foreach ( $ reflection -> getMethods ( ) as $ method ) { if ( $ method -> isPublic ( ) && ! $ method -> isConstructor ( ) ) { $ comment = $ method -> getDocComment ( ) ; if ( preg_match ( '/@nohook[ \t\*\n]+/' ,...
Process hooks .
15,633
public static function removeHook ( $ tag , $ class , $ name , $ priority = 10 ) { global $ wp_filter ; if ( isset ( $ wp_filter [ $ tag ] ) ) { if ( is_object ( $ wp_filter [ $ tag ] ) && isset ( $ wp_filter [ $ tag ] -> callbacks ) ) { $ fob = $ wp_filter [ $ tag ] ; $ callbacks = & $ wp_filter [ $ tag ] -> callbacks...
Removes an anonymous object filter .
15,634
public function checkDate ( $ value , ExecutionContextInterface $ context ) { $ format = self :: PHP_DATE_FORMAT ; if ( ! empty ( $ value ) && false === \ DateTime :: createFromFormat ( $ format , $ value ) ) { $ context -> addViolation ( Translator :: getInstance ( ) -> trans ( "Date '%date' is invalid, please enter a...
Validate a date entered with the current edition Language date format .
15,635
protected function initRequest ( Lang $ lang = null ) { $ container = $ this -> getContainer ( ) ; $ request = Request :: create ( $ this -> getBaseUrl ( $ lang ) ) ; $ request -> setSession ( new Session ( new MockArraySessionStorage ( ) ) ) ; $ container -> set ( "request_stack" , new RequestStack ( ) ) ; $ container...
For init an Request if your command has need an Request
15,636
public function duplicate ( $ token , Customer $ customer = null , Currency $ currency = null , EventDispatcherInterface $ dispatcher = null ) { if ( ! $ dispatcher ) { return false ; } $ cartItems = $ this -> getCartItems ( ) ; $ cart = new Cart ( ) ; $ cart -> setAddressDeliveryId ( $ this -> getAddressDeliveryId ( )...
Duplicate the current existing cart . Only the token is changed
15,637
public function getLastCartItemAdded ( ) { return CartItemQuery :: create ( ) -> filterByCartId ( $ this -> getId ( ) ) -> orderByCreatedAt ( Criteria :: DESC ) -> findOne ( ) ; }
Retrieve the last item added in the cart
15,638
public function getTotalVAT ( $ taxCountry , $ taxState = null ) { return ( $ this -> getTaxedAmount ( $ taxCountry , true , $ taxState ) - $ this -> getTotalAmount ( true ) ) ; }
Return the VAT of all items
15,639
public function getWeight ( ) { $ weight = 0 ; foreach ( $ this -> getCartItems ( ) as $ cartItem ) { $ itemWeight = $ cartItem -> getProductSaleElements ( ) -> getWeight ( ) ; $ itemWeight *= $ cartItem -> getQuantity ( ) ; $ weight += $ itemWeight ; } return $ weight ; }
Retrieve the total weight for all products in cart
15,640
public function isVirtual ( ) { foreach ( $ this -> getCartItems ( ) as $ cartItem ) { if ( 0 < $ cartItem -> getProductSaleElements ( ) -> getWeight ( ) ) { return false ; } $ product = $ cartItem -> getProductSaleElements ( ) -> getProduct ( ) ; if ( ! $ product -> getVirtual ( ) ) { return false ; } } return true ; ...
Tell if the cart contains only virtual products
15,641
protected function createComponentConfigurationForm ( ) : Form { $ form = $ this -> formFactory -> create ( ) ; $ form -> setAjaxRequest ( ) ; $ form -> addGroup ( 'cms.settings.basic' ) ; $ form -> addImageUpload ( 'cmsLogo' , 'cms.settings.logo' , 'cms.settings.deleteLogo' ) -> setNamespace ( 'cms' ) -> setPreview ( ...
Komponenta formulare nastaveni
15,642
public static function init ( $ name = 'boldgrid_settings' , $ key = 'library' ) { self :: $ name = $ name ; self :: $ key = $ key ; self :: $ option = self :: getOption ( ) ; }
Initialize the option utility .
15,643
public static function set ( $ key , $ value ) { self :: $ option [ self :: $ key ] [ $ key ] = $ value ; return update_option ( self :: $ name , self :: $ option ) ; }
Set option key value .
15,644
public static function delete ( $ key ) { unset ( self :: $ option [ self :: $ key ] [ $ key ] ) ; return update_option ( self :: $ name , self :: $ option ) ; }
Deletes by key in stored option .
15,645
public static function get ( $ key = null , $ default = array ( ) ) { return $ key && ! empty ( self :: $ option [ $ key ] ) ? self :: $ option [ $ key ] : $ default ; }
Retrieves an option key from the array .
15,646
final public function hasRequiredRole ( UserInterface $ user = null , array $ roles = [ ] ) { if ( $ user != null ) { $ userRoles = $ user -> getRoles ( ) ; foreach ( $ userRoles as $ role ) { if ( \ in_array ( $ role , $ roles ) ) { return true ; } } } return false ; }
Check if a user has at least one of the required roles
15,647
final public function isGranted ( array $ roles , array $ resources , array $ modules , array $ accesses ) { $ user = $ this -> checkRole ( $ roles ) ; if ( null === $ user ) { return false ; } else { return $ this -> isUserGranted ( $ roles , $ resources , $ modules , $ accesses , $ user ) ; } }
Checks if the current user is allowed
15,648
public function checkRole ( array $ roles ) { $ user = $ this -> getCustomerUser ( ) ; if ( ! $ this -> hasRequiredRole ( $ user , $ roles ) ) { $ user = $ this -> getAdminUser ( ) ; if ( ! $ this -> hasRequiredRole ( $ user , $ roles ) ) { $ user = null ; } } return $ user ; }
look if a user has the required role .
15,649
private function insertOrReplaceTag ( $ content , $ search , $ replace ) { $ newContent = null ; $ regexSearch = "/(\<$search\>\<\!\[CDATA\[([0-9.])+\]\]\>\<\/$search\>)/" ; if ( preg_match ( $ regexSearch , $ content ) ) { $ newContent = preg_replace ( $ regexSearch , $ replace , $ content ) ; } else { $ newContent = ...
This method modifies the XML plugin data and looks for width tags and replaces the value
15,650
private function updateMelisPlugin ( $ pageId , $ plugin , $ pluginId , $ content , $ updateSettings = false ) { $ pluginContent = $ content ; $ pluginSessionSettings = isset ( $ _SESSION [ 'meliscms' ] [ 'content-pages' ] [ $ pageId ] [ 'private:melisPluginSettings' ] [ $ pluginId ] ) ? $ _SESSION [ 'meliscms' ] [ 'co...
This method modifies the tag plugin xml attribute applying the changes of the width
15,651
private function setPluginWidthXmlAttribute ( $ pluginXml , $ pluginSettings ) { try { $ pluginDesktop = isset ( $ pluginSettings [ 'width_desktop' ] ) ? $ pluginSettings [ 'width_desktop' ] : 100 ; $ pluginTablet = isset ( $ pluginSettings [ 'width_tablet' ] ) ? $ pluginSettings [ 'width_tablet' ] : 100 ; $ pluginMobi...
This method will setup the width of the plugin xml config
15,652
public function getWeight ( ) { $ weight = 0 ; foreach ( $ this -> getOrderProducts ( ) as $ orderProduct ) { $ weight += $ orderProduct -> getQuantity ( ) * ( double ) $ orderProduct -> getWeight ( ) ; } return $ weight ; }
Compute this order weight .
15,653
public function getUntaxedPostage ( ) { if ( 0 < $ this -> getPostageTax ( ) ) { $ untaxedPostage = $ this -> getPostage ( ) - $ this -> getPostageTax ( ) ; } else { $ untaxedPostage = $ this -> getPostage ( ) ; } return $ untaxedPostage ; }
Return the postage without tax
15,654
public function hasVirtualProduct ( ) { $ virtualProductCount = OrderProductQuery :: create ( ) -> filterByOrderId ( $ this -> getId ( ) ) -> filterByVirtual ( 1 , Criteria :: EQUAL ) -> count ( ) ; return ( $ virtualProductCount !== 0 ) ; }
Check if the current order contains at less 1 virtual product with a file to download
15,655
public function setStatusHelper ( $ statusCode ) { if ( null !== $ ordeStatus = OrderStatusQuery :: create ( ) -> findOneByCode ( $ statusCode ) ) { $ this -> setOrderStatus ( $ ordeStatus ) -> save ( ) ; } }
Set the status of the current order to the provided status
15,656
public function getPaymentModuleInstance ( ) { if ( null === $ paymentModule = ModuleQuery :: create ( ) -> findPk ( $ this -> getPaymentModuleId ( ) ) ) { throw new TheliaProcessException ( "Payment module ID=" . $ this -> getPaymentModuleId ( ) . " was not found." ) ; } return $ paymentModule -> createInstance ( ) ; ...
Get an instance of the payment module
15,657
public function getDeliveryModuleInstance ( ) { if ( null === $ deliveryModule = ModuleQuery :: create ( ) -> findPk ( $ this -> getDeliveryModuleId ( ) ) ) { throw new TheliaProcessException ( "Delivery module ID=" . $ this -> getDeliveryModuleId ( ) . " was not found." ) ; } return $ deliveryModule -> createInstance ...
Get an instance of the delivery module
15,658
public static function getFromName ( $ messageName ) { if ( false === $ message = MessageQuery :: create ( ) -> filterByName ( $ messageName ) -> findOne ( ) ) { throw new \ Exception ( "Failed to load message $messageName." ) ; } return $ message ; }
Load a message from its name throwing an excemtoipn is none is found .
15,659
protected function init ( $ product , $ dependency = 'boldgrid/library' ) { $ this -> product = $ product ; $ this -> dependency = $ dependency ; Option :: init ( ) ; $ this -> libraries = Option :: get ( 'library' ) ; $ this -> verify ( ) ; }
Initialize class and set class properties .
15,660
public function register ( ) { $ version = new Version ( $ this -> getDependency ( ) ) ; Option :: set ( $ this -> getProduct ( ) , $ version -> getVersion ( ) ) ; }
Register the product in WordPress options .
15,661
public function isValid ( IsValidPaymentEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ module = $ event -> getModule ( ) ; $ dispatcher -> dispatch ( TheliaEvents :: getModuleEvent ( TheliaEvents :: MODULE_PAYMENT_IS_VALID , $ module -> getCode ( ) ) , $ event ) ; if ( $ event -> isPropagatio...
Check if a module is valid
15,662
protected function getRememberMeKeyFromCookie ( Request $ request , $ cookieName ) { $ ctp = new CookieTokenProvider ( ) ; return $ ctp -> getKeyFromCookie ( $ request , $ cookieName ) ; }
Get the remember me key from the cookie .
15,663
protected function createRememberMeCookie ( UserInterface $ user , $ cookieName , $ cookieExpiration ) { $ ctp = new CookieTokenProvider ( ) ; $ ctp -> createCookie ( $ user , $ cookieName , $ cookieExpiration ) ; }
Create the remember me cookie for the given user .
15,664
public function toUpperCase ( ) { $ token = $ this -> getConstantName ( ) -> lastToken ( ) ; $ token -> setText ( strtoupper ( $ token -> getText ( ) ) ) ; return $ this ; }
Convert the constant into uppercase .
15,665
public function toLowerCase ( ) { $ token = $ this -> getConstantName ( ) -> lastToken ( ) ; $ token -> setText ( strtolower ( $ token -> getText ( ) ) ) ; return $ this ; }
Convert the constant into lowercase .
15,666
public function listen ( $ channel , $ expr , callable $ handler ) { $ this -> adapter -> subscribe ( $ channel , function ( $ message ) use ( $ expr , $ handler ) { $ this -> handleSubscribeCallback ( $ message , $ expr , $ handler ) ; } ) ; }
Listen for an event .
15,667
public function dispatchBatch ( $ channel , array $ events ) { $ messages = [ ] ; $ validates = true ; foreach ( $ events as $ event ) { $ event = $ this -> prepEventForDispatch ( $ event ) ; if ( $ this -> validator ) { $ result = $ this -> validator -> validate ( $ event ) ; if ( $ result -> fails ( ) ) { $ validates...
Dispatch multiple events .
15,668
public function make ( array $ config ) { Arr :: requires ( $ config , [ 'from' , 'token' ] ) ; $ client = new Client ( ) ; return new CampfireGateway ( $ client , $ config ) ; }
Create a new campfire gateway instance .
15,669
public function getTableNames ( GetPropertyOptionsEvent $ event ) { if ( ! $ this -> isBackendOptionRequestFor ( $ event , [ 'tag_table' ] ) ) { return ; } $ sqlTable = $ this -> translator -> trans ( 'tl_metamodel_attribute.tag_table_type.sql-table' , [ ] , 'contao_tl_metamodel_attribute' ) ; $ translated = $ this -> ...
Retrieve all database table names and store them into the event .
15,670
public function getColumnNames ( GetPropertyOptionsEvent $ event ) { if ( ! $ this -> isBackendOptionRequestFor ( $ event , [ 'tag_column' , 'tag_alias' , 'tag_sorting' ] ) ) { return ; } $ result = $ this -> getColumnNamesFrom ( $ event -> getModel ( ) -> getProperty ( 'tag_table' ) ) ; if ( ! empty ( $ result ) ) { \...
Retrieve all column names for the current selected table .
15,671
public function checkQuery ( EncodePropertyValueFromWidgetEvent $ event ) { if ( ! $ this -> scopeMatcher -> currentScopeIsBackend ( ) ) { return ; } if ( ( 'tl_metamodel_attribute' !== $ event -> getEnvironment ( ) -> getDataDefinition ( ) -> getName ( ) ) || ( 'tag_where' !== $ event -> getProperty ( ) ) ) { return ;...
Check if the select_where value is valid by firing a test query .
15,672
private function getColumnNamesFrom ( $ table ) { if ( 0 === \ strpos ( $ table , 'mm_' ) ) { $ attributes = $ this -> getAttributeNamesFrom ( $ table ) ; \ asort ( $ attributes ) ; $ sql = $ this -> translator -> trans ( 'tl_metamodel_attribute.tag_column_type.sql' , [ ] , 'contao_tl_metamodel_attribute' ) ; $ attribu...
Retrieve all column names for the given table .
15,673
private function addCondition ( $ property , $ condition ) { $ currentCondition = $ property -> getVisibleCondition ( ) ; if ( ( ! ( $ currentCondition instanceof ConditionChainInterface ) ) || ( $ currentCondition -> getConjunction ( ) != ConditionChainInterface :: OR_CONJUNCTION ) ) { if ( $ currentCondition === null...
Add a condition to a property .
15,674
private function isBackendOptionRequestFor ( $ event , $ fields ) { if ( ! $ this -> scopeMatcher -> currentScopeIsBackend ( ) ) { return false ; } return ( 'tl_metamodel_attribute' === $ event -> getEnvironment ( ) -> getDataDefinition ( ) -> getName ( ) ) && \ in_array ( $ event -> getPropertyName ( ) , $ fields ) ; ...
Test if the event is an option request for any of the passed fields .
15,675
protected function getClosestAcceptedCashAmount ( $ amount ) : int { $ value = Number :: fromString ( $ amount ) -> getIntegerPart ( ) ; $ cent = $ amount % 5 ; if ( $ cent <= 2 ) { $ value = $ value - $ cent ; } else { $ value = $ value + ( 5 - $ cent ) ; } return $ value ; }
Get closest accepted cash amount .
15,676
public static function getUri ( ) { $ nginx_port = Docker :: getContainerPort ( Compose :: getContainerName ( self :: projectName ( ) , 'nginx' ) , 80 ) ; if ( ! $ nginx_port ) { throw new \ RuntimeException ( "nginx container is not running" ) ; } return "http://localhost:$nginx_port" ; }
Gets the uri to access the site .
15,677
public static function create ( $ class_name , $ method_name ) { if ( is_string ( $ class_name ) ) { $ class_name = NameNode :: create ( $ class_name ) ; } $ node = new static ( ) ; $ node -> addChild ( $ class_name , 'className' ) ; $ node -> addChild ( Token :: doubleColon ( ) ) ; $ node -> addChild ( Token :: identi...
Creates a method call on a class with an empty argument list .
15,678
public function clearCache ( CachedFileEvent $ event ) { $ path = $ this -> getCachePath ( $ event -> getCacheSubdirectory ( ) , false ) ; $ this -> clearDirectory ( $ path ) ; }
Clear the file cache . Is a subdirectory is specified only this directory is cleared . If no directory is specified the whole cache is cleared . Only files are deleted directories will remain .
15,679
protected function clearDirectory ( $ path ) { $ iterator = new \ DirectoryIterator ( $ path ) ; foreach ( $ iterator as $ fileinfo ) { if ( $ fileinfo -> isDot ( ) ) { continue ; } if ( $ fileinfo -> isFile ( ) || $ fileinfo -> isLink ( ) ) { @ unlink ( $ fileinfo -> getPathname ( ) ) ; } elseif ( $ fileinfo -> isDir ...
Recursively clears the specified directory .
15,680
protected function getCacheFileURL ( $ subdir , $ safe_filename ) { $ path = $ this -> getCachePathFromWebRoot ( $ subdir ) ; return URL :: getInstance ( ) -> absoluteUrl ( sprintf ( "%s/%s" , $ path , $ safe_filename ) , null , URL :: PATH_TO_FILE , $ this -> cdnBaseUrl ) ; }
Return the absolute URL to the cached file
15,681
protected function getCacheFilePath ( $ subdir , $ filename , $ forceOriginalFile = false , $ hashed_options = null ) { $ path = $ this -> getCachePath ( $ subdir ) ; $ safe_filename = preg_replace ( "[^:alnum:\-\._]" , "-" , strtolower ( basename ( $ filename ) ) ) ; if ( $ forceOriginalFile || $ hashed_options == nul...
Return the full path of the cached file
15,682
protected function getCachePathFromWebRoot ( $ subdir = null ) { $ cache_dir_from_web_root = $ this -> getCacheDirFromWebRoot ( ) ; if ( $ subdir != null ) { $ safe_subdir = basename ( $ subdir ) ; $ path = sprintf ( "%s/%s" , $ cache_dir_from_web_root , $ safe_subdir ) ; } else { $ path = $ cache_dir_from_web_root ; }...
Return the cache directory path relative to Web Root
15,683
protected function getCachePath ( $ subdir = null , $ create_if_not_exists = true ) { $ cache_base = $ this -> getCachePathFromWebRoot ( $ subdir ) ; $ web_root = rtrim ( THELIA_WEB_DIR , '/' ) ; $ path = sprintf ( "%s/%s" , $ web_root , $ cache_base ) ; if ( $ create_if_not_exists && ! is_dir ( $ path ) ) { if ( ! @ m...
Return the absolute cache directory path
15,684
public function saveFile ( FileCreateOrUpdateEvent $ event ) { $ model = $ event -> getModel ( ) ; $ model -> setFile ( sprintf ( "tmp/%s" , $ event -> getUploadedFile ( ) -> getFilename ( ) ) ) ; $ con = Propel :: getWriteConnection ( ProductImageTableMap :: DATABASE_NAME ) ; $ con -> beginTransaction ( ) ; try { $ nb...
Take care of saving a file in the database and file storage
15,685
public function updateFile ( FileCreateOrUpdateEvent $ event ) { if ( $ event -> getUploadedFile ( ) ) { $ url = $ event -> getModel ( ) -> getUploadDir ( ) . '/' . $ event -> getOldModel ( ) -> getFile ( ) ; unlink ( str_replace ( '..' , '' , $ url ) ) ; $ newUploadedFile = $ this -> fileManager -> copyUploadedFile ( ...
Take care of updating file in the database and file storage
15,686
public function addFragment ( Fragment $ fragment ) { if ( ! empty ( $ this -> fields ) ) { $ fragment -> filter ( $ this -> fields ) ; } $ this -> fragmentBag -> addFragment ( $ fragment ) ; return $ this ; }
Add a new fragment
15,687
private function setMessages ( ) { $ allowed_html = array ( 'a' => array ( 'href' => array ( ) , ) , 'strong' => array ( ) , ) ; $ msg = new \ stdClass ( ) ; $ msg -> success = sprintf ( wp_kses ( __ ( 'Your api key has been saved. To change, see <strong>Settings &#187; <a href="%1$s">BoldGrid Connect</a></strong>.' , ...
Sets the messages returned by key prompt .
15,688
public static function getState ( ) { $ state = 'no-key-added' ; $ license = Configs :: get ( 'start' ) -> getKey ( ) -> getLicense ( ) ; if ( $ license ) { $ isPremium = $ license -> isPremium ( 'boldgrid-inspirations' ) ; $ license = $ isPremium ? 'premium' : 'basic' ; $ state = $ license . '-key-active' ; } return $...
Get the current state of the BoldGrid Connect Key .
15,689
public function keyNotice ( ) { $ display_notice = apply_filters ( 'Boldgrid\Library\Library\Notice\KeyPrompt_display' , ( ! Library \ Notice :: isDismissed ( $ this -> userNoticeKey ) ) ) ; if ( $ display_notice ) { $ current_user = wp_get_current_user ( ) ; $ email = $ current_user -> user_email ; $ first_name = empt...
Displays the notice .
15,690
public function addKey ( ) { delete_site_transient ( 'bg_license_data' ) ; delete_site_transient ( 'boldgrid_api_data' ) ; $ key = $ this -> validate ( ) ; $ data = $ this -> key -> callCheckVersion ( array ( 'key' => $ key ) ) ; $ msg = $ this -> getMessages ( ) ; if ( is_object ( $ data ) ) { $ this -> key -> save ( ...
Key input handling .
15,691
protected function validate ( ) { $ msg = $ this -> getMessages ( ) ; if ( ! isset ( $ _POST [ 'set_key_auth' ] ) || ! check_ajax_referer ( 'boldgrid_set_key' , 'set_key_auth' , false ) ) { wp_send_json_error ( array ( 'message' => $ msg -> nonce ) ) ; } if ( empty ( $ _POST [ 'api_key' ] ) ) { wp_send_json_error ( arr...
Handles validation of user input on API key entry form .
15,692
public function getIsDismissed ( ) { if ( is_null ( self :: $ isDismissed ) ) { self :: $ isDismissed = Library \ Notice :: isDismissed ( $ this -> userNoticeKey ) ; } return self :: $ isDismissed ; }
Get static class property isDismissed .
15,693
public function isActive ( TemplateDefinition $ tplDefinition ) { $ tplVar = '' ; switch ( $ tplDefinition -> getType ( ) ) { case TemplateDefinition :: FRONT_OFFICE : $ tplVar = 'active-front-template' ; break ; case TemplateDefinition :: BACK_OFFICE : $ tplVar = 'active-admin-template' ; break ; case TemplateDefiniti...
Check if a template definition is the current active template
15,694
public function getList ( $ templateType , $ base = THELIA_TEMPLATE_DIR ) { $ list = $ exclude = array ( ) ; $ tplIterator = TemplateDefinition :: getStandardTemplatesSubdirsIterator ( ) ; foreach ( $ tplIterator as $ type => $ subdir ) { if ( $ templateType == $ type ) { $ baseDir = rtrim ( $ base , DS ) . DS . $ subd...
Return a list of existing templates for a given template type
15,695
public function browseAction ( ) { if ( null !== $ response = $ this -> checkAuth ( AdminResources :: COUPON , [ ] , AccessManager :: VIEW ) ) { return $ response ; } return $ this -> render ( 'coupon-list' , [ 'coupon_order' => $ this -> getListOrderFromSession ( 'coupon' , 'coupon_order' , 'code' ) ] ) ; }
Manage Coupons list display
15,696
public function createAction ( ) { if ( null !== $ response = $ this -> checkAuth ( AdminResources :: COUPON , [ ] , AccessManager :: CREATE ) ) { return $ response ; } $ args = [ ] ; $ eventToDispatch = TheliaEvents :: COUPON_CREATE ; if ( $ this -> getRequest ( ) -> isMethod ( 'POST' ) ) { if ( null !== $ response = ...
Manage Coupons creation display
15,697
protected function logError ( $ action , $ message , $ e ) { Tlog :: getInstance ( ) -> error ( sprintf ( 'Error during Coupon ' . $ action . ' process : %s. Exception was %s' , $ message , $ e -> getMessage ( ) ) ) ; return $ this ; }
Log error message
15,698
protected function validateCreateOrUpdateForm ( $ eventToDispatch , $ log , $ action , Coupon $ model = null ) { $ couponForm = $ this -> getForm ( $ action , $ model ) ; $ response = null ; $ message = false ; try { $ form = $ this -> validateForm ( $ couponForm , 'POST' ) ; $ couponEvent = $ this -> feedCouponCreateO...
Validate the CreateOrUpdate form
15,699
protected function getAvailableConditions ( ) { $ couponManager = $ this -> container -> get ( 'thelia.coupon.manager' ) ; $ availableConditions = $ couponManager -> getAvailableConditions ( ) ; $ cleanedConditions = [ ] ; foreach ( $ availableConditions as $ availableCondition ) { $ condition = [ ] ; $ condition [ 'se...
Get all available conditions