idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
33,000 | protected function _getProductListTypeItem ( $ domain , $ code ) { if ( ! isset ( $ this -> _listTypeAttributes [ $ domain ] [ $ code ] ) ) { $ listTypeManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'product/list/type' ) ; $ listTypeSearch = $ listTypeManager -> createSearch ( true ) ; $ expr = array ( $ listTypeSearch -> compare ( '==' , 'product.list.type.domain' , $ domain ) , $ listTypeSearch -> compare ( '==' , 'product.list.type.code' , $ code ) , $ listTypeSearch -> getConditions ( ) , ) ; $ listTypeSearch -> setConditions ( $ listTypeSearch -> combine ( '&&' , $ expr ) ) ; $ listTypeItems = $ listTypeManager -> searchItems ( $ listTypeSearch ) ; if ( ( $ listTypeItem = reset ( $ listTypeItems ) ) === false ) { $ msg = sprintf ( 'List type for domain "%1$s" and code "%2$s" not found' , $ domain , $ code ) ; throw new Controller_Frontend_Basket_Exception ( $ msg ) ; } $ this -> _listTypeAttributes [ $ domain ] [ $ code ] = $ listTypeItem ; } return $ this -> _listTypeAttributes [ $ domain ] [ $ code ] ; } | Returns the list type item for the given domain and code . |
33,001 | protected function _getProductVariants ( MShop_Product_Item_Interface $ productItem , array $ variantAttributeIds , array $ domains = array ( 'attribute' , 'media' , 'price' , 'text' ) ) { $ subProductIds = array ( ) ; foreach ( $ productItem -> getRefItems ( 'product' , 'default' , 'default' ) as $ item ) { $ subProductIds [ ] = $ item -> getId ( ) ; } if ( count ( $ subProductIds ) === 0 ) { return array ( ) ; } $ productManager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'product' ) ; $ search = $ productManager -> createSearch ( true ) ; $ expr = array ( $ search -> compare ( '==' , 'product.id' , $ subProductIds ) , $ search -> getConditions ( ) , ) ; if ( count ( $ variantAttributeIds ) > 0 ) { $ listTypeItem = $ this -> _getProductListTypeItem ( 'attribute' , 'variant' ) ; $ param = array ( 'attribute' , $ listTypeItem -> getId ( ) , $ variantAttributeIds ) ; $ cmpfunc = $ search -> createFunction ( 'product.contains' , $ param ) ; $ expr [ ] = $ search -> compare ( '==' , $ cmpfunc , count ( $ variantAttributeIds ) ) ; } $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; return $ productManager -> searchItems ( $ search , $ domains ) ; } | Returns the product variants of a selection product that match the given attributes . |
33,002 | public function docGenerate ( ) { $ this -> _exec ( 'cd ' . __DIR__ . '/docs && composer install' ) ; $ this -> _exec ( __DIR__ . '/docs/build' ) ; $ this -> _exec ( __DIR__ . '/vendor/bin/couscous preview' ) ; } | Generates the projects documentation . |
33,003 | public function build ( ) { $ files = $ this -> iterator -> getFiles ( ) ; $ generators = $ this -> generatorRegistry -> generators ( ) ; foreach ( $ files as $ file ) { foreach ( $ generators as $ generator ) { $ generator -> parseFile ( $ file ) ; } } foreach ( $ generators as $ generator ) { $ generator -> generate ( ) ; } } | Index build method . |
33,004 | public static function createController ( MShop_Context_Item_Interface $ context , $ name = null ) { if ( $ name === null ) { $ name = $ context -> getConfig ( ) -> get ( 'classes/controller/common/order/name' , 'Default' ) ; } if ( ctype_alnum ( $ name ) === false ) { $ classname = is_string ( $ name ) ? 'Controller_Common_Order_' . $ name : '<not a string>' ; throw new Controller_Common_Exception ( sprintf ( 'Invalid characters in class name "%1$s"' , $ classname ) ) ; } $ iface = 'Controller_Common_Order_Interface' ; $ classname = 'Controller_Common_Order_' . $ name ; if ( isset ( self :: $ _objects [ $ classname ] ) ) { return self :: $ _objects [ $ classname ] ; } if ( class_exists ( $ classname ) === false ) { throw new Controller_Common_Exception ( sprintf ( 'Class "%1$s" not available' , $ classname ) ) ; } $ controller = new $ classname ( $ context ) ; if ( ! ( $ controller instanceof $ iface ) ) { throw new Controller_Common_Exception ( sprintf ( 'Class "%1$s" does not implement interface "%2$s"' , $ classname , $ interface ) ) ; } return $ controller ; } | Creates a new controller specified by the given name . |
33,005 | public static function sum ( $ items , $ callback = null ) { $ callback = static :: valueRetriever ( $ callback ) ; $ sum = null ; foreach ( $ items as $ item ) { if ( ( $ amount = $ callback ( $ item ) ) !== null ) { $ sum = $ sum ? $ sum -> add ( $ amount ) : $ amount ; } } return $ sum ? : static :: zero ( ) ; } | Retrieve the sum of an array . |
33,006 | public function enable ( $ name ) { $ marray = array ( ) ; foreach ( ( array ) $ name as $ item ) { $ marray [ ] = str_replace ( '$' , $ item , $ this -> _begin ) ; $ marray [ ] = str_replace ( '$' , $ item , $ this -> _end ) ; } $ this -> _text = str_replace ( $ marray , '' , $ this -> _text ) ; return $ this ; } | Removes the maker and enables content in template . |
33,007 | public function disable ( $ name ) { $ list = array ( ) ; foreach ( ( array ) $ name as $ item ) { $ list [ $ item ] = '' ; } $ this -> substitute ( $ list ) ; return $ this ; } | Removes the content between the marker . |
33,008 | public function get ( $ name ) { $ mbegin = str_replace ( '$' , $ name , $ this -> _begin ) ; $ mend = str_replace ( '$' , $ name , $ this -> _end ) ; if ( ( $ begin = strpos ( $ this -> _text , $ mbegin ) ) === false ) { throw new MW_Template_Exception ( sprintf ( 'Error finding begin of marker "%1$s" in template' , $ name ) ) ; } $ begin += strlen ( $ mbegin ) ; if ( ( $ end = strpos ( $ this -> _text , $ mend , $ begin ) ) === false ) { throw new MW_Template_Exception ( sprintf ( 'Error finding end of marker "%1$s" in template' , $ name ) ) ; } return new self ( substr ( $ this -> _text , $ begin , $ end - $ begin ) , $ this -> _begin , $ this -> _end ) ; } | Returns a new template object containing the requested part from the template . |
33,009 | public function substitute ( array $ substitute ) { foreach ( $ substitute as $ marker => $ value ) { $ begin = 0 ; $ mbegin = ( string ) str_replace ( '$' , $ marker , $ this -> _begin ) ; $ mend = ( string ) str_replace ( '$' , $ marker , $ this -> _end ) ; while ( ( $ begin = strpos ( $ this -> _text , $ mbegin , $ begin ) ) !== false ) { if ( ( $ end = strpos ( $ this -> _text , $ mend , $ begin + strlen ( $ mbegin ) ) ) === false ) { throw new MW_Template_Exception ( sprintf ( 'Error finding end of marker "%1$s" in template' , $ marker ) ) ; } $ this -> _text = substr_replace ( $ this -> _text , $ value , $ begin , $ end + strlen ( $ mend ) - $ begin ) ; } } return $ this ; } | Substitutes the marker by given text . |
33,010 | public function str ( $ remove = true ) { if ( $ remove === false ) { return $ this -> _text ; } $ matches = array ( ) ; $ text = $ this -> _text ; $ regex = '/' . str_replace ( '\$' , '(.*)' , preg_quote ( $ this -> _begin , '/' ) ) . '/U' ; if ( preg_match_all ( $ regex , $ text , $ matches ) === false ) { throw new MW_Template_Exception ( sprintf ( 'Invalid regular expression: %1$s' , $ regex ) ) ; } $ matches = array_unique ( $ matches [ 1 ] ) ; foreach ( $ matches as $ match ) { $ begin = str_replace ( '\$' , $ match , preg_quote ( $ this -> _begin , '/' ) ) ; $ end = str_replace ( '\$' , $ match , preg_quote ( $ this -> _end , '/' ) ) ; $ regex = '/' . $ begin . '.*' . $ end . '/smU' ; if ( ( $ text = preg_replace ( $ regex , '' , $ text ) ) === null ) { throw new MW_Template_Exception ( sprintf ( 'Invalid regular expression: %1$s' , $ regex ) ) ; } } return $ text ; } | Generates the template by replacing substrings and remove markers . |
33,011 | public function publish ( $ channel , $ data , $ id = null , $ prev_id = null ) { $ pub = $ this -> get_pubcontrol ( ) ; $ pub -> publish ( $ channel , new \ PubControl \ Item ( new JsonObjectFormat ( $ data ) , $ id , $ prev_id ) ) ; } | ID to send along with the message . |
33,012 | public function publish_async ( $ channel , $ data , $ id = null , $ prev_id = null , $ callback = null ) { $ pub = $ this -> get_pubcontrol ( ) ; $ pub -> publish_async ( $ channel , new \ PubControl \ Item ( new JsonObjectFormat ( $ data ) , $ id , $ prev_id ) , $ callback ) ; } | if an error was encountered . |
33,013 | protected function _getCatalogIds ( MShop_Catalog_Item_Interface $ tree , array $ path , $ currentId ) { if ( $ tree -> getId ( ) == $ currentId ) { $ ids = array ( ) ; foreach ( $ tree -> getChildren ( ) as $ item ) { $ ids [ ] = $ item -> getId ( ) ; } return $ ids ; } foreach ( $ tree -> getChildren ( ) as $ child ) { if ( isset ( $ path [ $ child -> getId ( ) ] ) ) { return $ this -> _getCatalogIds ( $ child , $ path , $ currentId ) ; } } return array ( ) ; } | Returns the category IDs of the given catalog tree . |
33,014 | public function updateCoupon ( MShop_Order_Item_Base_Interface $ base ) { if ( $ this -> _getObject ( ) -> isAvailable ( $ base ) !== true ) { $ base -> deleteCoupon ( $ this -> _code ) ; return ; } $ this -> deleteCoupon ( $ base ) ; $ this -> addCoupon ( $ base ) ; } | Updates the result of a coupon to the order base instance . |
33,015 | protected function _getConfigValue ( $ key , $ default = null ) { $ config = $ this -> _item -> getConfig ( ) ; if ( isset ( $ config [ $ key ] ) ) { return $ config [ $ key ] ; } return $ default ; } | Returns the configuration value from the service item specified by its key . |
33,016 | protected function _createProduct ( $ productCode , $ quantity = 1 , $ warehouse = 'default' ) { $ productManager = MShop_Factory :: createManager ( $ this -> _context , 'product' ) ; $ search = $ productManager -> createSearch ( true ) ; $ search -> setConditions ( $ search -> compare ( '==' , 'product.code' , $ productCode ) ) ; $ products = $ productManager -> searchItems ( $ search , array ( 'text' , 'media' , 'price' ) ) ; if ( ( $ product = reset ( $ products ) ) === false ) { throw new MShop_Coupon_Exception ( sprintf ( 'No product with code "%1$s" found' , $ productCode ) ) ; } $ priceManager = MShop_Factory :: createManager ( $ this -> _context , 'price' ) ; $ prices = $ product -> getRefItems ( 'price' , 'default' , 'default' ) ; if ( empty ( $ prices ) ) { $ price = $ priceManager -> createItem ( ) ; } else { $ price = $ priceManager -> getLowestPrice ( $ prices , $ quantity ) ; } $ orderBaseProductManager = MShop_Factory :: createManager ( $ this -> _context , 'order/base/product' ) ; $ orderProduct = $ orderBaseProductManager -> createItem ( ) ; $ orderProduct -> copyFrom ( $ product ) ; $ orderProduct -> setQuantity ( $ quantity ) ; $ orderProduct -> setWarehouseCode ( $ warehouse ) ; $ orderProduct -> setPrice ( $ price ) ; $ orderProduct -> setFlags ( MShop_Order_Item_Base_Product_Abstract :: FLAG_IMMUTABLE ) ; return $ orderProduct ; } | Creates an order product from the product item . |
33,017 | protected function _createMonetaryRebateProducts ( MShop_Order_Item_Base_Interface $ base , $ productCode , $ rebate , $ quantity = 1 , $ warehouse = 'default' ) { $ orderProducts = array ( ) ; $ prices = $ this -> _getPriceByTaxRate ( $ base ) ; krsort ( $ prices ) ; if ( empty ( $ prices ) ) { $ prices = array ( '0.00' => MShop_Factory :: createManager ( $ this -> _getContext ( ) , 'price' ) -> createItem ( ) ) ; } foreach ( $ prices as $ taxrate => $ price ) { if ( abs ( $ rebate ) < 0.01 ) { break ; } $ amount = $ price -> getValue ( ) + $ price -> getCosts ( ) ; if ( $ amount > 0 && $ amount < $ rebate ) { $ value = $ price -> getValue ( ) + $ price -> getCosts ( ) ; $ rebate -= $ value ; } else { $ value = $ rebate ; $ rebate = '0.00' ; } $ orderProduct = $ this -> _createProduct ( $ productCode , $ quantity , $ warehouse ) ; $ price = $ orderProduct -> getPrice ( ) ; $ price -> setValue ( - $ value ) ; $ price -> setRebate ( $ value ) ; $ price -> setTaxRate ( $ taxrate ) ; $ orderProduct -> setPrice ( $ price ) ; $ orderProducts [ ] = $ orderProduct ; } return $ orderProducts ; } | Creates the order products for monetary rebates . |
33,018 | protected function _getPriceByTaxRate ( MShop_Order_Item_Base_Interface $ basket ) { $ taxrates = array ( ) ; foreach ( $ basket -> getProducts ( ) as $ product ) { $ price = $ product -> getPrice ( ) ; $ taxrate = $ price -> getTaxRate ( ) ; if ( isset ( $ taxrates [ $ taxrate ] ) ) { $ taxrates [ $ taxrate ] -> addItem ( $ price ) ; } else { $ taxrates [ $ taxrate ] = $ price ; } } try { $ price = $ basket -> getService ( 'delivery' ) -> getPrice ( ) ; $ taxrate = $ price -> getTaxRate ( ) ; if ( isset ( $ taxrates [ $ taxrate ] ) ) { $ taxrates [ $ taxrate ] -> addItem ( $ price ) ; } else { $ taxrates [ $ taxrate ] = $ price ; } } catch ( Exception $ e ) { ; } try { $ price = $ basket -> getService ( 'payment' ) -> getPrice ( ) ; $ taxrate = $ price -> getTaxRate ( ) ; if ( isset ( $ taxrates [ $ taxrate ] ) ) { $ taxrates [ $ taxrate ] -> addItem ( $ price ) ; } else { $ taxrates [ $ taxrate ] = $ price ; } } catch ( Exception $ e ) { ; } return $ taxrates ; } | Returns a list of tax rates and their price items for the given basket . |
33,019 | protected function _process ( array $ stmts ) { $ table = 'mshop_plugin' ; $ constraint = 'fk_msplu_typeid' ; $ this -> _msg ( 'Adding constraint for table mshop_plugin' , 0 ) ; $ this -> _status ( '' ) ; $ this -> _msg ( sprintf ( 'Checking constraint "%1$s": ' , $ constraint ) , 1 ) ; if ( $ this -> _schema -> tableExists ( $ table ) === true && $ this -> _schema -> columnExists ( $ table , 'typeid' ) && $ this -> _schema -> constraintExists ( $ table , $ constraint ) === false ) { $ this -> _execute ( $ stmts [ $ constraint ] ) ; $ this -> _status ( 'added' ) ; } else { $ this -> _status ( 'OK' ) ; } } | Adds typeid constraint to mshop_plugin if necessary . |
33,020 | public function delete ( $ files , array $ options = [ ] ) { collect ( array_wrap ( $ options ) ) -> each ( function ( $ file ) { Storage :: delete ( sprintf ( '%s/%s' , $ this -> uploadFolder , array_get ( $ file , 'filename' ) ) ) ; } ) ; return response ( ) -> json ( 'Files deleted' , 200 ) ; } | Deletes a file from the media library . Only the original file will be deleted incase resized versions are in use . |
33,021 | public function resources ( String $ type = null ) { return [ 'resources' => collect ( Storage :: files ( $ this -> uploadFolder ) ) -> filter ( function ( $ file ) { return ! str_is ( "{$this->uploadFolder}.*" , $ file ) ; } ) -> map ( function ( $ file ) { $ fileParts = pathinfo ( $ file ) ; return [ 'public_id' => array_get ( $ fileParts , 'filename' ) , 'format' => array_get ( $ fileParts , 'extension' ) , ] ; } ) -> all ( ) ] ; } | Return a list of local media resources . Currently the type parameter is not supported in the default local media driver . |
33,022 | private function getFileFromOptions ( $ file , $ options = [ ] ) { extract ( $ options ) ; $ originalFilename = "{$file['public_id']}.{$file['format']}" ; $ resizedFilename = "{$file['public_id']}_{$width}_{$height}_{$gravity}.{$file['format']}" ; $ image = Image :: make ( Storage :: get ( "{$this->uploadFolder}/{$originalFilename}" ) ) ; if ( ! $ width || ! $ height ) { $ image -> resize ( $ width , $ height , function ( $ constraint ) { $ constraint -> aspectRatio ( ) ; } ) ; } else { $ image -> fit ( $ width , $ height ) ; } $ image -> save ( public_path ( "/{$this->mediaFolder}/{$resizedFilename}" ) ) ; return "/{$this->mediaFolder}/{$resizedFilename}" ; } | Process a media item and return the resized version of the file |
33,023 | protected static function _createManager ( MShop_Context_Item_Interface $ context , $ classname , $ interface ) { if ( isset ( self :: $ _objects [ $ classname ] ) ) { return self :: $ _objects [ $ classname ] ; } if ( class_exists ( $ classname ) === false ) { throw new MShop_Exception ( sprintf ( 'Class "%1$s" not available' , $ classname ) ) ; } $ manager = new $ classname ( $ context ) ; if ( ! ( $ manager instanceof $ interface ) ) { throw new MShop_Exception ( sprintf ( 'Class "%1$s" does not implement interface "%2$s"' , $ classname , $ interface ) ) ; } return $ manager ; } | Creates a manager object . |
33,024 | function startCountingAddedLevels ( ) { foreach ( $ this -> getSchema ( ) -> getLevels ( ) as $ level ) { $ select = $ this -> getReadAdapter ( ) -> select ( ) -> from ( 'elite_level_' . $ this -> getSchema ( ) -> id ( ) . '_' . str_replace ( ' ' , '_' , $ level ) , 'count(*)' ) ; $ result = $ select -> query ( ) -> fetchColumn ( ) ; $ this -> start_count_added_by_level [ $ level ] = $ result ; } } | Probe how many Make Model Year there are before the import |
33,025 | public function getContactsAsAssoc ( ) { $ list = array ( ) ; foreach ( $ this -> contacts as $ contact ) { $ list [ $ contact -> name ] = $ contact ; } return $ list ; } | Gets the current contact list . |
33,026 | public function getContactIds ( ) { $ list = array ( ) ; foreach ( $ this -> contacts as $ contact ) { $ list [ $ contact -> name ] = $ contact -> id ; } return $ list ; } | Gets contact id . |
33,027 | public function getContact ( $ id ) { foreach ( $ this -> contacts as $ contact ) { if ( $ contact -> id == $ id ) { return $ contact ; } } throw new Exception ( "Contact '$id' not found" ) ; } | Gets the contact with the given id . |
33,028 | public function addContacts ( $ contacts ) { if ( ! is_array ( $ contacts ) ) { return false ; } foreach ( $ contacts as $ contact ) { if ( ! ( $ contact instanceof contact ) ) { return false ; } } $ this -> contacts = array_merge ( $ this -> contacts , $ contacts ) ; return true ; } | add a list of contact . |
33,029 | public function addAssocContacts ( $ contacts ) { if ( ! is_array ( $ contacts ) ) { return false ; } foreach ( $ contacts as $ name => $ contact ) { if ( is_object ( $ contact ) && $ contact instanceof SoapVar ) { $ contact = $ contact -> enc_value ; } if ( ! ( $ contact instanceof contact ) ) { return false ; } if ( $ name != $ contact -> name ) { return false ; } $ this -> contacts [ ] = $ contact ; } return true ; } | add an associative list of contact . |
33,030 | public function saveContact ( contact $ contact ) { $ contact -> save ( ) ; foreach ( $ this -> contacts as $ k => $ contactdb ) { if ( $ contactdb -> id == $ contact -> id ) { $ this -> contacts [ $ k ] = $ contact ; return ; } } $ this -> contacts [ ] = $ contact ; } | Saves a given contact . |
33,031 | public function setTypeId ( $ typeId ) { if ( $ typeId == $ this -> getTypeId ( ) ) { return ; } $ this -> _values [ 'typeid' ] = ( int ) $ typeId ; $ this -> setModified ( ) ; } | Sets the type ID of the service item . |
33,032 | protected function _checkLock ( $ value ) { switch ( $ value ) { case MShop_Order_Manager_Base_Abstract :: LOCK_DISABLE : case MShop_Order_Manager_Base_Abstract :: LOCK_ENABLE : break ; default : throw new MShop_Order_Exception ( sprintf ( 'Lock flag "%1$d" not within allowed range' , $ value ) ) ; } } | Checks if the lock value is a valid constant . |
33,033 | protected function loadFile ( string $ file , array $ options ) { if ( isset ( $ options [ 'num' ] ) || isset ( $ options [ 'callbacks' ] ) ) { throw new BadMethodCallException ( "Options 'num' and 'callbacks' aren't supported with the Symfony" . " YAML parser. Please install the yaml PHP extension." ) ; } try { return $ this -> parser -> parseFile ( $ file , Yaml :: PARSE_OBJECT_FOR_MAP ) ; } catch ( ParseException $ parseException ) { $ err = $ parseException -> getMessage ( ) ; throw new LoadException ( "Failed to load settings from '$file': {$err}" , 0 , $ parseException ) ; } } | Parse a yaml file |
33,034 | protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'order.base.id' : $ item -> setId ( $ value ) ; break ; case 'order.base.comment' : $ item -> setComment ( $ value ) ; break ; case 'order.base.customerid' : $ item -> setCustomerId ( $ value ) ; break ; } } return $ item ; } | Creates a new order base item and sets the properties from the given array . |
33,035 | private function setupAutowire ( array $ config , ContainerBuilder $ container ) { if ( ! method_exists ( $ container , 'autowire' ) ) { return ; } if ( ! $ config [ 'autowire' ] ) { return ; } if ( ! array_key_exists ( 'default' , $ config [ 'clients' ] ) ) { return ; } if ( $ container -> hasDefinition ( Client :: class ) ) { throw new LogicException ( 'Default Elasticsearch client autowiring setup is enabled, ' . 'but Elastica client service is already defined in container' ) ; } $ container -> setAlias ( Client :: class , $ this -> createClientId ( 'default' ) ) ; } | Configure service auto - wiring for default Elastica client for Symfony 3 . 3 + |
33,036 | public static function fromSuccess ( array $ params ) { $ matchResult = new self ( ) ; $ matchResult -> type = 'success' ; $ matchResult -> params = $ params ; return $ matchResult ; } | Creates a success match result . |
33,037 | public static function fromMethodFailure ( array $ allowedMethods ) { $ matchResult = new self ( ) ; $ matchResult -> type = 'methodFailure' ; $ matchResult -> allowedMethods = $ allowedMethods ; return $ matchResult ; } | Creates a method failure match reuslt . |
33,038 | public static function fromSchemeFailure ( UriInterface $ absoluteUri ) { $ matchResult = new self ( ) ; $ matchResult -> type = 'schemeFailure' ; $ matchResult -> absoluteUri = $ absoluteUri ; return $ matchResult ; } | Creates a scheme failure match result . |
33,039 | public static function fromChildMatch ( self $ childMatchResult , $ parentParams , $ childRouteName ) { if ( ! $ childMatchResult -> isSuccess ( ) ) { throw new DomainException ( 'Child match must be a successful match result' ) ; } $ matchResult = self :: fromSuccess ( $ childMatchResult -> getParams ( ) + $ parentParams ) ; $ matchResult -> routeName = $ childRouteName ; if ( null !== $ childMatchResult -> getRouteName ( ) ) { $ matchResult -> routeName .= '/' . $ childMatchResult -> getRouteName ( ) ; } return $ matchResult ; } | Creates a new match result from a child match . |
33,040 | public static function mergeMethodFailures ( self $ firstMatchResult , self $ secondMatchResult ) { if ( ! $ firstMatchResult -> isMethodFailure ( ) || ! $ secondMatchResult -> isMethodFailure ( ) ) { throw new DomainException ( 'Both match results must be method failures' ) ; } return self :: fromMethodFailure ( array_unique ( array_merge ( $ firstMatchResult -> getAllowedMethods ( ) , $ secondMatchResult -> getAllowedMethods ( ) ) ) ) ; } | Merges two method failure match results . |
33,041 | protected function _process ( $ stmt ) { $ table = 'madmin_log' ; $ this -> _msg ( 'Changing site ID to NULL in madmin_log' , 0 ) ; $ this -> _status ( '' ) ; $ this -> _msg ( sprintf ( 'Changing table "%1$s": ' , $ table ) , 1 ) ; if ( $ this -> _schema -> tableExists ( $ table ) && ! $ this -> _schema -> getColumnDetails ( $ table , 'siteid' ) -> isNullable ( ) ) { $ this -> _execute ( $ stmt ) ; $ this -> _status ( 'done' ) ; } else { $ this -> _status ( 'OK' ) ; } } | Changes site ID to NULL in madmin_log . |
33,042 | public function setAddressId ( $ addrid ) { if ( $ addrid == $ this -> getAddressId ( ) ) { return ; } $ this -> _values [ 'addrid' ] = ( string ) $ addrid ; $ this -> setModified ( ) ; } | Sets the original customer address ID . |
33,043 | public function setType ( $ type ) { if ( $ type == $ this -> getType ( ) ) { return ; } $ this -> _checkType ( $ type ) ; $ this -> _values [ 'type' ] = ( string ) $ type ; $ this -> setModified ( ) ; } | Sets the new type of the address which can be billing or delivery . |
33,044 | public function copyFrom ( MShop_Common_Item_Address_Interface $ address ) { $ this -> setAddressId ( $ address -> getId ( ) ) ; $ this -> setCompany ( $ address -> getCompany ( ) ) ; $ this -> setVatID ( $ address -> getVatID ( ) ) ; $ this -> setSalutation ( $ address -> getSalutation ( ) ) ; $ this -> setTitle ( $ address -> getTitle ( ) ) ; $ this -> setFirstname ( $ address -> getFirstname ( ) ) ; $ this -> setLastname ( $ address -> getLastname ( ) ) ; $ this -> setAddress1 ( $ address -> getAddress1 ( ) ) ; $ this -> setAddress2 ( $ address -> getAddress2 ( ) ) ; $ this -> setAddress3 ( $ address -> getAddress3 ( ) ) ; $ this -> setPostal ( $ address -> getPostal ( ) ) ; $ this -> setCity ( $ address -> getCity ( ) ) ; $ this -> setState ( $ address -> getState ( ) ) ; $ this -> setCountryId ( $ address -> getCountryId ( ) ) ; $ this -> setTelephone ( $ address -> getTelephone ( ) ) ; $ this -> setEmail ( $ address -> getEmail ( ) ) ; $ this -> setTelefax ( $ address -> getTelefax ( ) ) ; $ this -> setWebsite ( $ address -> getWebsite ( ) ) ; $ this -> setLanguageId ( $ address -> getLanguageId ( ) ) ; $ this -> setFlag ( $ address -> getFlag ( ) ) ; $ this -> setModified ( ) ; } | Copys all data from a given address . |
33,045 | protected function _createItem ( array $ entry ) { $ item = $ this -> _manager -> createItem ( ) ; foreach ( $ entry as $ name => $ value ) { switch ( $ name ) { case 'locale.id' : $ item -> setId ( $ value ) ; break ; case 'locale.siteid' : $ item -> setSiteId ( $ value ) ; break ; case 'locale.languageid' : $ item -> setLanguageId ( $ value ) ; break ; case 'locale.currencyid' : $ item -> setCurrencyId ( $ value ) ; break ; case 'locale.position' : $ item -> setPosition ( $ value ) ; break ; case 'locale.status' : $ item -> setStatus ( $ value ) ; break ; } } return $ item ; } | Creates a new locale item and sets the properties from the given array . |
33,046 | protected function _addCouponDecorators ( MShop_Coupon_Item_Interface $ item , $ code , MShop_Coupon_Provider_Interface $ provider , array $ names ) { $ iface = 'MShop_Coupon_Provider_Decorator_Interface' ; $ classprefix = 'MShop_Coupon_Provider_Decorator_' ; foreach ( $ names as $ name ) { if ( ctype_alnum ( $ name ) === false ) { throw new MShop_Coupon_Exception ( sprintf ( 'Invalid characters in class name "%1$s"' , $ name ) ) ; } $ classname = $ classprefix . $ name ; if ( class_exists ( $ classname ) === false ) { throw new MShop_Coupon_Exception ( sprintf ( 'Class "%1$s" not available' , $ classname ) ) ; } $ provider = new $ classname ( $ this -> _getContext ( ) , $ item , $ code , $ provider ) ; if ( ( $ provider instanceof $ iface ) === false ) { throw new MShop_Coupon_Exception ( sprintf ( 'Class "%1$s" does not implement interface "%2$s"' , $ classname , $ iface ) ) ; } } return $ provider ; } | Wraps the named coupon decorators around the coupon provider . |
33,047 | public static function rewriteConfiguration ( ) { $ config = Configuration :: get ( ) ; $ config [ 'name' ] = Yii :: $ app -> config -> get ( Enum :: APP_NAME ) ; $ cacheClass = Yii :: $ app -> config -> get ( Enum :: CACHE_CLASS ) ; if ( ! $ cacheClass ) { $ cacheClass = FileCache :: className ( ) ; } $ config [ 'components' ] [ 'cache' ] = [ 'class' => $ cacheClass ] ; $ config [ 'components' ] [ 'authClientCollection' ] [ 'class' ] = 'yii\\authclient\\Collection' ; Configuration :: set ( $ config ) ; } | Rewrites the configuration file |
33,048 | public static function get ( ) { $ configFile = Yii :: $ app -> params [ Enum :: CONFIG_FILE ] ; $ config = require ( $ configFile ) ; if ( ! is_array ( $ config ) ) return [ ] ; return $ config ; } | Returns the dynamic configuration file as array |
33,049 | public static function set ( $ config = [ ] ) { $ configFile = Yii :: $ app -> params [ Enum :: CONFIG_FILE ] ; $ content = "<" . "?php return " ; $ content .= var_export ( $ config , TRUE ) ; $ content .= "; ?" . ">" ; file_put_contents ( $ configFile , $ content ) ; if ( function_exists ( 'opcache_reset' ) ) { opcache_invalidate ( $ configFile ) ; } } | Sets configuration into the file |
33,050 | public static function getParam ( ) { $ paramFile = Yii :: $ app -> params [ Enum :: PARAMS_FILE ] ; $ param = require ( $ paramFile ) ; if ( ! is_array ( $ param ) ) return [ ] ; return $ param ; } | Returns the dynamic params file as array |
33,051 | public static function setParam ( $ config = [ ] ) { $ paramFile = Yii :: $ app -> params [ Enum :: PARAMS_FILE ] ; $ content = "<" . "?php return " ; $ content .= var_export ( $ config , TRUE ) ; $ content .= "; ?" . ">" ; file_put_contents ( $ paramFile , $ content ) ; if ( function_exists ( 'opcache_reset' ) ) { opcache_invalidate ( $ paramFile ) ; } } | Sets params into the file |
33,052 | public function saveItem ( MShop_Common_Item_Interface $ item , $ fetch = true ) { $ iface = 'MShop_Common_Item_Type_Interface' ; if ( ! ( $ item instanceof $ iface ) ) { throw new MShop_Exception ( sprintf ( 'Object is not of required type "%1$s"' , $ iface ) ) ; } if ( $ item -> isModified ( ) === false ) { return ; } $ dbm = $ this -> _context -> getDatabaseManager ( ) ; $ dbname = $ this -> _getResourceName ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ id = $ item -> getId ( ) ; if ( $ id === null ) { $ sql = $ this -> _config [ 'insert' ] ; } else { $ sql = $ this -> _config [ 'update' ] ; } $ statement = $ conn -> create ( $ sql ) ; $ statement -> bind ( 1 , $ this -> _context -> getLocale ( ) -> getSiteId ( ) , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ statement -> bind ( 2 , $ item -> getCode ( ) , MW_DB_Statement_Abstract :: PARAM_STR ) ; $ statement -> bind ( 3 , $ item -> getDomain ( ) , MW_DB_Statement_Abstract :: PARAM_STR ) ; $ statement -> bind ( 4 , $ item -> getLabel ( ) , MW_DB_Statement_Abstract :: PARAM_STR ) ; $ statement -> bind ( 5 , $ item -> getStatus ( ) , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ statement -> bind ( 6 , date ( 'Y-m-d H:i:s' , time ( ) ) ) ; $ statement -> bind ( 7 , $ this -> _context -> getEditor ( ) ) ; if ( $ id !== null ) { $ statement -> bind ( 8 , $ id , MW_DB_Statement_Abstract :: PARAM_INT ) ; } else { $ statement -> bind ( 8 , date ( 'Y-m-d H:i:s' , time ( ) ) ) ; } $ statement -> execute ( ) -> finish ( ) ; if ( $ fetch === true ) { if ( $ id === null ) { $ item -> setId ( $ this -> _newId ( $ conn , $ this -> _config [ 'newid' ] ) ) ; } else { $ item -> setId ( $ id ) ; } } $ dbm -> release ( $ conn , $ dbname ) ; } catch ( Exception $ e ) { $ dbm -> release ( $ conn , $ dbname ) ; throw $ e ; } } | Adds or updates a type item object . |
33,053 | public function getItem ( $ id , array $ ref = array ( ) ) { $ conf = reset ( $ this -> _searchConfig ) ; $ criteria = $ this -> createSearch ( ) ; $ criteria -> setConditions ( $ criteria -> compare ( '==' , $ conf [ 'code' ] , $ id ) ) ; $ items = $ this -> searchItems ( $ criteria , $ ref ) ; if ( ( $ item = reset ( $ items ) ) === false ) { throw new MShop_Exception ( sprintf ( 'Type item with ID "%1$s" in "%2$s" not found' , $ id , $ conf [ 'code' ] ) ) ; } return $ item ; } | Returns the type item specified by its ID |
33,054 | public function searchItems ( MW_Common_Criteria_Interface $ search , array $ ref = array ( ) , & $ total = null ) { $ items = array ( ) ; $ dbm = $ this -> _context -> getDatabaseManager ( ) ; $ dbname = $ this -> _getResourceName ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ domain = explode ( '.' , $ this -> _prefix ) ; if ( ( $ topdomain = array_shift ( $ domain ) ) === null ) { throw new MShop_Exception ( 'No configuration available.' ) ; } $ level = MShop_Locale_Manager_Abstract :: SITE_ALL ; $ cfgPathSearch = $ this -> _config [ 'search' ] ; $ cfgPathCount = $ this -> _config [ 'count' ] ; $ required = array ( trim ( $ this -> _prefix , '.' ) ) ; $ results = $ this -> _searchItems ( $ conn , $ search , $ cfgPathSearch , $ cfgPathCount , $ required , $ total , $ level ) ; while ( ( $ row = $ results -> fetch ( ) ) !== false ) { $ items [ $ row [ 'id' ] ] = $ this -> _createItem ( $ row ) ; } $ dbm -> release ( $ conn , $ dbname ) ; } catch ( Exception $ e ) { $ dbm -> release ( $ conn , $ dbname ) ; throw $ e ; } return $ items ; } | Searches for all type items matching the given critera . |
33,055 | public function scopeSearch ( $ query , $ search ) { return $ query -> whereName ( $ search ) -> orWhere ( 'id' , intval ( $ search ) ) -> orWhere ( 'slug' , intval ( $ search ) ) ; } | Query scope for searching permission . |
33,056 | public function removePermission ( $ ids ) { $ ids = is_array ( $ ids ) ? $ ids : func_get_args ( ) ; $ this -> permissions ( ) -> detach ( $ ids ) ; } | Detach permission from role . |
33,057 | public function can ( $ name ) { foreach ( $ this -> permissions as $ permission ) { if ( $ permission -> name == $ name || $ permission -> id == $ name ) { return true ; } } return false ; } | Determine wether the current role has permission that given by name parameter . |
33,058 | protected function determineLoader ( $ source ) : LoaderInterface { expect_type ( $ source , [ 'object' , 'string' ] ) ; return is_object ( $ source ) ? $ this -> determineLoaderFromClass ( $ source ) : $ this -> determineLoaderFromPath ( $ source ) ; } | Determine loader from source |
33,059 | protected function determineLoaderFromClass ( $ source ) : LoaderInterface { foreach ( $ this -> loaders as $ key => $ loader ) { if ( class_exists ( $ key ) && is_a ( $ source , $ key ) ) { return $ loader ; } } $ desc = get_class ( $ source ) . ' ' . gettype ( $ source ) ; throw new NoLoaderException ( "Don't know how to load configuration from $desc" ) ; } | Determine the loader based on the classname of the object |
33,060 | protected function determineLoaderFromPath ( string $ source ) : LoaderInterface { if ( isset ( $ this -> loaders [ $ source ] ) ) { return $ this -> loaders [ $ source ] ; } $ key = is_dir ( $ source ) ? 'dir' : ( pathinfo ( $ source , PATHINFO_EXTENSION ) ? : null ) ; if ( ! isset ( $ key ) || ! isset ( $ this -> loaders [ $ key ] ) ) { throw new NoLoaderException ( "Don't know how to load configuration from '$source'" ) ; } return $ this -> loaders [ $ key ] ; } | Determine loader based on file extension |
33,061 | public static function getDefaultLoaders ( LoaderInterface $ fileLoader = null ) : array { $ loaders = [ 'dir' => new Loader \ DirLoader ( ) , 'ini' => new Loader \ IniLoader ( ) , 'json' => new Loader \ JsonLoader ( ) , 'yaml' => function_exists ( 'yaml_parse' ) ? new Loader \ YamlLoader ( ) : new Loader \ YamlSymfonyLoader ( ) , 'env' => new Loader \ EnvLoader ( ) , 'Aws\DynamoDb\DynamoDbClient' => new Loader \ DynamoDBLoader ( ) ] ; $ loaders [ 'yml' ] = $ loaders [ 'yaml' ] ; if ( isset ( $ fileLoader ) ) { $ loaders [ 'dir' ] -> setFileLoader ( $ fileLoader ) ; } return $ loaders ; } | Get the default loaders . |
33,062 | protected function _initOptions ( $ options ) { $ defaultOptions = array ( 'soap_version' => SOAP_1_1 , 'authentication' => SOAP_AUTHENTICATION_BASIC , 'features' => SOAP_SINGLE_ELEMENT_ARRAYS , 'exceptions' => true , 'timeout' => ( int ) ini_get ( 'default_socket_timeout' ) , ) ; $ options = array_merge ( $ defaultOptions , $ options ) ; ini_set ( 'default_socket_timeout' , ( int ) $ options [ 'timeout' ] ) ; return $ options ; } | init the options . |
33,063 | public static function errorHandlerForFatal ( $ errno , $ errstr , $ errfile = null , $ errline = null ) { $ code = self :: $ _defaultCode ; self :: stopErrorHandlerForFatal ( ) ; if ( $ errstr instanceof Exception ) { if ( $ errstr -> getCode ( ) ) { $ code = $ errstr -> getCode ( ) ; } $ errstr = $ errstr -> getMessage ( ) ; } elseif ( ! is_string ( $ errstr ) ) { $ errstr = 'Unknown error' ; } throw new SoapFault ( $ code , $ errstr . ' (error [' . $ errno . '])' ) ; } | handling the error to catch fatal errors . |
33,064 | public function getRelatedMessage ( ) { if ( $ this -> has ( 'message' ) ) { return $ this -> getMessage ( ) ; } elseif ( $ this -> has ( 'edited_message' ) ) { return $ this -> getEditedMessage ( ) ; } elseif ( $ this -> has ( 'callback_query' ) ) { return $ this -> getCallbackQuery ( ) -> getMessage ( ) ; } elseif ( $ this -> has ( 'channel_post' ) ) { return $ this -> getChannelPost ( ) ; } elseif ( $ this -> has ( 'edited_channel_post' ) ) { return $ this -> getEditedChannelPost ( ) ; } } | Return the related message . |
33,065 | public function getFrom ( ) { if ( $ this -> has ( 'message' ) ) { return $ this -> getMessage ( ) -> getFrom ( ) ; } elseif ( $ this -> has ( 'edited_message' ) ) { return $ this -> getEditedMessage ( ) -> getFrom ( ) ; } elseif ( $ this -> has ( 'inline_query' ) ) { return $ this -> getInlineQuery ( ) -> getFrom ( ) ; } elseif ( $ this -> has ( 'chosen_inline_result' ) ) { return $ this -> getChosenInlineResult ( ) -> getFrom ( ) ; } elseif ( $ this -> has ( 'callback_query' ) ) { return $ this -> getCallbackQuery ( ) -> getFrom ( ) ; } elseif ( $ this -> has ( 'channel_post' ) ) { return $ this -> getChannelPost ( ) -> getFrom ( ) ; } elseif ( $ this -> has ( 'edited_channel_post' ) ) { return $ this -> getEditedChannelPost ( ) -> getFrom ( ) ; } } | Return the related user that created the update . |
33,066 | protected function _createArray ( MShop_Product_Item_Interface $ item ) { return array ( 'id' => $ item -> getId ( ) , 'typeid' => $ item -> getTypeId ( ) , 'type' => $ item -> getType ( ) , 'status' => $ item -> getStatus ( ) , 'label' => $ item -> getLabel ( ) , 'start' => $ item -> getDateStart ( ) , 'end' => $ item -> getDateEnd ( ) , 'code' => $ item -> getCode ( ) , 'suppliercode' => $ item -> getSupplierCode ( ) , 'ctime' => $ item -> getTimeCreated ( ) , 'mtime' => $ item -> getTimeModified ( ) , 'editor' => $ item -> getEditor ( ) , ) ; } | Create new product item object initialized with given parameters . |
33,067 | public function addRole ( $ idOrName ) { $ ids = is_array ( $ idOrName ) ? $ idOrName : func_get_args ( ) ; foreach ( $ ids as $ search ) { $ role = Role :: search ( $ idOrName ) -> firstOrFail ( ) ; $ this -> roles ( ) -> attach ( $ role -> id ) ; } } | Add role to user . |
33,068 | public function removeRole ( $ idOrName ) { $ ids = is_array ( $ idOrName ) ? $ idOrName : func_get_args ( ) ; foreach ( $ ids as $ search ) { $ role = Role :: search ( $ search ) -> firstOrFail ( ) ; $ this -> roles ( ) -> detach ( $ role -> id ) ; } } | Remove role from user . |
33,069 | public function is ( $ name ) { foreach ( $ this -> roles as $ role ) { if ( $ role -> name == $ name || $ role -> slug == $ name || $ role -> id == $ name ) { return true ; } } return false ; } | Determine whether the user has role that given by name parameter . |
33,070 | public function can ( $ name ) { foreach ( $ this -> roles as $ role ) { foreach ( $ role -> permissions as $ permission ) { if ( $ permission -> name == $ name || $ permission -> slug == $ name || $ permission -> id == $ name ) { return true ; } } } return false ; } | Determine whether the user can do specific permission that given by name parameter . |
33,071 | public function getPermissionsAttribute ( ) { $ permissions = new Collection ( ) ; foreach ( $ this -> roles as $ role ) { foreach ( $ role -> permissions as $ permission ) { $ permissions -> push ( $ permission ) ; } } return $ permissions ; } | Get permissions attribute . |
33,072 | protected function _process ( ) { $ iface = 'MShop_Context_Item_Interface' ; if ( ! ( $ this -> _additional instanceof $ iface ) ) { throw new MW_Setup_Exception ( sprintf ( 'Additionally provided object is not of type "%1$s"' , $ iface ) ) ; } $ this -> _msg ( 'Adding warehouse data' , 0 ) ; $ ds = DIRECTORY_SEPARATOR ; $ path = dirname ( __FILE__ ) . $ ds . 'default' . $ ds . 'data' . $ ds . 'warehouse.php' ; if ( ( $ data = include ( $ path ) ) == false ) { throw new MShop_Exception ( sprintf ( 'No file "%1$s" found for product stock domain' , $ path ) ) ; } $ manager = MShop_Product_Manager_Factory :: createManager ( $ this -> _additional ) ; $ warehouseManager = $ manager -> getSubManager ( 'stock' ) -> getSubManager ( 'warehouse' ) ; $ num = $ total = 0 ; $ item = $ warehouseManager -> createItem ( ) ; foreach ( $ data [ 'warehouse' ] as $ key => $ dataset ) { $ total ++ ; $ item -> setId ( null ) ; $ item -> setCode ( $ dataset [ 'code' ] ) ; $ item -> setLabel ( $ dataset [ 'label' ] ) ; $ item -> setStatus ( $ dataset [ 'status' ] ) ; try { $ warehouseManager -> saveItem ( $ item ) ; $ num ++ ; } catch ( MW_DB_Exception $ e ) { ; } } $ this -> _status ( $ num > 0 ? $ num . '/' . $ total : 'OK' ) ; } | Adds product stock test data . |
33,073 | protected function _process ( array $ stmts ) { $ this -> _msg ( 'Changing list ids to NOT NULL' , 0 ) ; $ this -> _status ( '' ) ; foreach ( $ stmts as $ tablename => $ stmt ) { $ this -> _msg ( sprintf ( 'Checking table "%1$s": ' , $ tablename ) , 1 ) ; if ( $ this -> _schema -> tableExists ( $ tablename ) === true && $ this -> _schema -> getColumnDetails ( $ tablename , 'id' ) -> isNullable ( ) === true ) { $ this -> _execute ( $ stmt ) ; $ this -> _status ( 'migrated' ) ; } else { $ this -> _status ( 'OK' ) ; } } } | Changes list ids to NOT NULL . |
33,074 | protected function render ( $ template , array $ vars = [ ] ) { $ pluginTemplateFolder = $ this -> plugin -> getTemplateFolder ( ) ; if ( ! empty ( $ pluginTemplateFolder ) ) { $ loader = new \ Twig_Loader_Filesystem ( $ pluginTemplateFolder ) ; $ this -> app [ 'twig' ] -> getLoader ( ) -> addLoader ( $ loader ) ; } $ defaults = [ 'layout' => [ 'title' => preg_replace ( '/\\.[^.\\s]{3,4}$/' , '' , $ template ) ] ] ; $ vars = array_replace_recursive ( $ defaults , $ vars ) ; return $ this -> app [ 'twig' ] -> render ( $ template , $ vars ) ; } | render a template |
33,075 | public function find ( $ identity ) { if ( ! $ this -> primaryKey ) { throw new LogicException ( 'No primary key!' ) ; } return $ this -> select ( ) -> where ( $ this -> primaryKey , $ identity ) -> limit ( 1 ) -> query ( ) -> fetchRow ( ) ; } | Find a record by primary key |
33,076 | public function findMany ( array $ identities ) { if ( ! $ this -> primaryKey ) { throw new LogicException ( 'No primary key!' ) ; } return $ this -> select ( ) -> whereIn ( $ this -> primaryKey , $ identities ) -> query ( ) -> fetchAll ( ) ; } | Find many records by identity |
33,077 | public function select ( ) { if ( ! $ this -> tableName ) { throw new LogicException ( 'No table name specified' ) ; } $ q = $ this -> database -> select ( ) ; $ q -> table ( $ this -> tableName ) ; if ( $ this -> resultClass ) { $ q -> setResultClass ( $ this -> resultClass ) ; $ q -> setResultParams ( $ this -> resultParams ) ; } return $ q ; } | Helper function the provides the \ zsql \ Select object with the table name pre - populated . |
33,078 | public function insert ( ) { if ( ! $ this -> tableName ) { throw new LogicException ( 'No table name specified' ) ; } return $ this -> database -> insert ( ) -> table ( $ this -> tableName ) ; } | Insert a row into the model s table . If no table name is specified an exception will be thrown |
33,079 | public function update ( ) { if ( ! $ this -> tableName ) { throw new LogicException ( 'No table name specified' ) ; } return $ this -> database -> update ( ) -> table ( $ this -> tableName ) ; } | Update existing rows in the model s table . If no table name is specified an exception will be thrown |
33,080 | public function delete ( ) { if ( ! $ this -> tableName ) { throw new LogicException ( 'No table name specified' ) ; } return $ this -> database -> delete ( ) -> table ( $ this -> tableName ) ; } | Deletes existing rows from the model s table . If no table name is specified an exception will be thrown |
33,081 | public function setView ( MW_View_Interface $ view ) { $ this -> _view = $ view ; $ this -> _client -> setView ( $ view ) ; } | Sets the view object that will generate the HTML output . |
33,082 | public function setCode ( $ key ) { if ( $ key == $ this -> getCode ( ) ) { return ; } if ( strlen ( $ key ) != 3 || ctype_alpha ( $ key ) === false ) { throw new MShop_Locale_Exception ( sprintf ( 'Invalid characters in ISO currency code "%1$s"' , $ key ) ) ; } $ this -> _values [ 'code' ] = strtoupper ( $ key ) ; $ this -> _modified = true ; } | Sets the code of the currency . |
33,083 | public function scale ( $ width , $ height , $ fit = true ) { if ( ( $ info = getimagesize ( $ this -> _filename ) ) === false ) { throw new MW_Media_Exception ( 'Unable to retrive image size' ) ; } if ( $ fit === true ) { list ( $ width , $ height ) = $ this -> _getSizeFitted ( $ info [ 0 ] , $ info [ 1 ] , $ width , $ height ) ; if ( $ info [ 0 ] <= $ width && $ info [ 1 ] <= $ height ) { return ; } } if ( ( $ image = imagecreatetruecolor ( $ width , $ height ) ) === false ) { throw new MW_Media_Exception ( 'Unable to create new image' ) ; } if ( imagecopyresampled ( $ image , $ this -> _image , 0 , 0 , 0 , 0 , $ width , $ height , $ info [ 0 ] , $ info [ 1 ] ) === false ) { throw new MW_Media_Exception ( 'Unable to resize image' ) ; } imagedestroy ( $ this -> _image ) ; $ this -> _image = $ image ; } | Scales the image to the given width and height . |
33,084 | public function setBaseId ( $ id ) { if ( $ id == $ this -> getBaseId ( ) ) { return ; } $ this -> _values [ 'baseid' ] = ( int ) $ id ; $ this -> setModified ( ) ; } | Sets the ID of the basic order item which contains the order details . |
33,085 | public function setDateDelivery ( $ date ) { if ( $ date === $ this -> getDateDelivery ( ) ) { return ; } $ this -> _checkDateFormat ( $ date ) ; $ this -> _values [ 'datedelivery' ] = ( string ) $ date ; $ this -> setModified ( ) ; } | Sets the delivery date of the invoice . |
33,086 | public function setDatePayment ( $ date ) { if ( $ date === $ this -> getDatePayment ( ) ) { return ; } $ this -> _checkDateFormat ( $ date ) ; $ this -> _values [ 'datepayment' ] = ( string ) $ date ; $ this -> setModified ( ) ; } | Sets the purchase date of the invoice . |
33,087 | public function setRelatedId ( $ id ) { if ( $ id === $ this -> getRelatedId ( ) ) { return ; } $ id = ( int ) $ id ; $ this -> _values [ 'relatedid' ] = $ id ; $ this -> setModified ( ) ; } | Sets the related invoice ID . |
33,088 | protected function filterPrefix ( array $ arguments ) { if ( empty ( $ arguments ) ) { throw new InvalidCallException ( 'At least one argument needed' ) ; } $ path = array_shift ( $ arguments ) ; if ( ! is_string ( $ path ) ) { throw new InvalidParamException ( 'First argument should be a string' ) ; } if ( ! preg_match ( '#^[a-zA-Z0-9]+\:\/\/.*#' , $ path ) ) { throw new InvalidParamException ( 'No prefix detected in for path: ' . $ path ) ; } list ( $ prefix , $ path ) = explode ( '://' , $ path , 2 ) ; array_unshift ( $ arguments , $ path ) ; return array ( $ prefix , $ arguments ) ; } | Retrieve the prefix form an arguments array |
33,089 | public function setValue ( $ value ) { if ( $ value == $ this -> getValue ( ) ) { return ; } $ this -> _values [ 'value' ] = ( string ) $ value ; $ this -> setModified ( ) ; } | Sets the value of the order status . |
33,090 | public function run ( $ dbtype ) { foreach ( $ this -> _tasks as $ taskname => $ task ) { $ this -> _runTasks ( $ dbtype , array ( $ taskname ) ) ; } } | Executes all tasks for the given database type |
33,091 | protected function _runTasks ( $ dbtype , array $ tasknames , array $ stack = array ( ) ) { foreach ( $ tasknames as $ taskname ) { if ( in_array ( $ taskname , $ this -> _tasksDone ) ) { continue ; } if ( in_array ( $ taskname , $ stack ) ) { $ msg = 'Circular dependency for "%1$s" detected. Task stack: %2$s' ; throw new MW_Setup_Exception ( sprintf ( $ msg , $ taskname , implode ( ', ' , $ stack ) ) ) ; } $ stack [ ] = $ taskname ; if ( isset ( $ this -> _dependencies [ $ taskname ] ) ) { $ this -> _runTasks ( $ dbtype , ( array ) $ this -> _dependencies [ $ taskname ] , $ stack ) ; } if ( isset ( $ this -> _tasks [ $ taskname ] ) ) { $ this -> _tasks [ $ taskname ] -> run ( $ dbtype ) ; } $ this -> _tasksDone [ ] = $ taskname ; } } | Runs the given tasks depending on their dependencies . |
33,092 | public function createItem ( ) { $ context = $ this -> _getContext ( ) ; $ priceManager = MShop_Factory :: createManager ( $ context , 'price' ) ; $ values = array ( 'siteid' => $ context -> getLocale ( ) -> getSiteId ( ) ) ; return $ this -> _createItem ( $ priceManager -> createItem ( ) , $ values ) ; } | Create new order base product item object . |
33,093 | protected function _getSearchTypes ( array $ attributes ) { $ types = array ( ) ; $ iface = 'MW_Common_Criteria_Attribute_Interface' ; foreach ( $ attributes as $ key => $ item ) { if ( $ item instanceof $ iface ) { $ types [ $ item -> getCode ( ) ] = $ item -> getInternalType ( ) ; } else if ( isset ( $ item [ 'code' ] ) ) { $ types [ $ item [ 'code' ] ] = $ item [ 'internaltype' ] ; } else { throw new MW_Common_Exception ( sprintf ( 'Invalid attribute at position "%1$d"' , $ key ) ) ; } } return $ types ; } | Returns the attribute types for searching defined by the manager . |
33,094 | protected function _getSearchTranslations ( array $ attributes ) { $ translations = array ( ) ; $ iface = 'MW_Common_Criteria_Attribute_Interface' ; foreach ( $ attributes as $ key => $ item ) { if ( $ item instanceof $ iface ) { $ translations [ $ item -> getCode ( ) ] = $ item -> getInternalCode ( ) ; } else if ( isset ( $ item [ 'code' ] ) ) { $ translations [ $ item [ 'code' ] ] = $ item [ 'internalcode' ] ; } else { throw new MW_Common_Exception ( sprintf ( 'Invalid attribute at position "%1$d"' , $ key ) ) ; } } return $ translations ; } | Returns the attribute translations for searching defined by the manager . |
33,095 | function setKeyLength ( $ length ) { $ length >>= 5 ; if ( $ length > 8 ) { $ length = 8 ; } else if ( $ length < 4 ) { $ length = 4 ; } $ this -> Nk = $ length ; $ this -> key_size = $ length << 2 ; $ this -> explicit_key_length = true ; $ this -> changed = true ; } | Sets the key length |
33,096 | function setBlockLength ( $ length ) { $ length >>= 5 ; if ( $ length > 8 ) { $ length = 8 ; } else if ( $ length < 4 ) { $ length = 4 ; } $ this -> Nb = $ length ; $ this -> block_size = $ length << 2 ; $ this -> changed = true ; } | Sets the block length |
33,097 | function _generate_xor ( $ length , & $ iv ) { $ xor = '' ; $ block_size = $ this -> block_size ; $ num_blocks = floor ( ( $ length + ( $ block_size - 1 ) ) / $ block_size ) ; for ( $ i = 0 ; $ i < $ num_blocks ; $ i ++ ) { $ xor .= $ iv ; for ( $ j = 4 ; $ j <= $ block_size ; $ j += 4 ) { $ temp = substr ( $ iv , - $ j , 4 ) ; switch ( $ temp ) { case "\xFF\xFF\xFF\xFF" : $ iv = substr_replace ( $ iv , "\x00\x00\x00\x00" , - $ j , 4 ) ; break ; case "\x7F\xFF\xFF\xFF" : $ iv = substr_replace ( $ iv , "\x80\x00\x00\x00" , - $ j , 4 ) ; break 2 ; default : extract ( unpack ( 'Ncount' , $ temp ) ) ; $ iv = substr_replace ( $ iv , pack ( 'N' , $ count + 1 ) , - $ j , 4 ) ; break 2 ; } } } return $ xor ; } | Generate CTR XOR encryption key |
33,098 | public function getConnection ( ) { if ( null === $ this -> connection && null !== $ this -> connectionFactory ) { $ this -> connection = $ this -> connectionFactory -> createMysqli ( ) ; } return $ this -> connection ; } | Exposes the local connection object |
33,099 | public function quote ( $ value ) { if ( null === $ value ) { return 'NULL' ; } else if ( is_bool ( $ value ) ) { return ( $ value ? '1' : '0' ) ; } else if ( $ value instanceof Expression ) { return ( string ) $ value ; } else if ( is_integer ( $ value ) ) { return sprintf ( '%d' , $ value ) ; } else if ( is_float ( $ value ) ) { return sprintf ( '%f' , $ value ) ; } else { return "'" . $ this -> getConnection ( ) -> real_escape_string ( $ value ) . "'" ; } } | Quote a raw string |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.