idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
25,400
public function run ( ) { if ( PHP_SAPI !== 'cli' ) { throw new AppServiceException ( 'Warning: Script should be invoked via the CLI version of PHP, not the ' . PHP_SAPI . ' SAPI' ) ; } try { $ this -> socketService -> run ( ) ; } catch ( SocketServiceException $ e ) { throw new AppServiceException ( $ e -> getMessage ( ) ) ; } }
Run socket server
25,401
protected function getRolesFromSite ( $ site ) { $ newDataSet = new AnyDataset ( ) ; $ it = $ this -> user -> getRolesIterator ( $ site ) ; while ( $ it -> hasNext ( ) ) { $ sr = $ it -> moveNext ( ) ; $ dataArray = $ sr -> getFieldArray ( $ this -> user -> getRolesTable ( ) -> Role ) ; if ( sizeof ( $ dataArray ) > 0 ) { foreach ( $ dataArray as $ roles ) { $ siteName = $ sr -> getField ( $ this -> user -> getRolesTable ( ) -> Site ) ; if ( $ siteName == "_all" ) { $ siteName = $ this -> myWords -> Value ( "TEXT_ALLSITES" ) ; } $ newDataSet -> appendRow ( ) ; $ newDataSet -> addField ( $ this -> user -> getRolesTable ( ) -> Site , $ siteName ) ; $ newDataSet -> addField ( $ this -> user -> getRolesTable ( ) -> Role , $ roles ) ; } } } return $ newDataSet ; }
Get all rules from a site
25,402
protected function AddListLink ( $ block ) { $ para = new XmlParagraphCollection ( ) ; $ this -> _mainBlock -> addXmlnukeObject ( $ para ) ; $ this -> url -> addParam ( "action" , ModuleAction :: Listing ) ; $ link = new XmlAnchorCollection ( $ this -> url -> getUrl ( ) , "" ) ; $ link -> addXmlnukeObject ( new XmlnukeText ( $ this -> myWords -> Value ( "LINK_LISTROLES" ) ) ) ; $ para -> addXmlnukeObject ( $ link ) ; }
Add a go back link to list roles
25,403
protected function AddEditListToSite ( $ block , $ site , $ dataset ) { $ para = new XmlParagraphCollection ( ) ; $ this -> _mainBlock -> addXmlnukeObject ( $ para ) ; $ this -> url -> addParam ( "editsite" , $ site ) ; $ editList = new XmlEditList ( $ this -> _context , $ this -> myWords -> Value ( "EDITLIST_TITLE" , $ site ) , $ this -> url -> getUrl ( ) , true , false , true , true ) ; $ editList -> setDataSource ( $ dataset -> getIterator ( ) ) ; $ listField = new EditListField ( ) ; $ listField -> editlistName = "" ; $ listField -> fieldData = "role" ; $ editList -> addEditListField ( $ listField ) ; $ listField = new EditListField ( ) ; $ listField -> editlistName = $ this -> myWords -> Value ( "EDITLIST_ROLES" ) ; $ listField -> fieldData = $ this -> user -> getRolesTable ( ) -> Role ; $ editList -> addEditListField ( $ listField ) ; $ listField = new EditListField ( ) ; $ listField -> editlistName = $ this -> myWords -> Value ( "EDITLIST_SITES" ) ; $ listField -> fieldData = $ this -> user -> getRolesTable ( ) -> Site ; $ editList -> addEditListField ( $ listField ) ; $ para -> addXmlnukeObject ( $ editList ) ; }
Add EditList to site
25,404
public function setUa ( $ ua ) { $ this -> ua = $ this -> detector -> setUserAgent ( $ ua ) ; $ this -> setBrowser ( ) ; return $ this ; }
Set user agent
25,405
private function setBrowser ( ) { $ client = parse_user_agent ( $ this -> detector -> getUserAgent ( ) ) ; $ this -> browser = $ client [ 'browser' ] ; $ this -> setPlatform ( $ client [ 'platform' ] ) ; return $ this ; }
Set user browser
25,406
private function deviceDetect ( ) { $ this -> mobile = ( int ) $ this -> detector -> isMobile ( ) ; $ this -> tablet = ( int ) $ this -> detector -> isTablet ( ) ; if ( $ this -> mobile === 0 && $ this -> tablet === 0 ) { $ this -> pc = 1 ; } return $ this ; }
Detect client device
25,407
public function toArray ( ) { $ properties = get_object_vars ( $ this ) ; foreach ( $ properties as $ var => & $ value ) { if ( gettype ( $ value ) === 'object' ) { unset ( $ properties [ $ var ] ) ; } } return $ properties ; }
Get properties as array view
25,408
protected function registerAccountChartTypeInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\System\Repositories\AccountChartType\AccountChartTypeInterface' , function ( ) { return new \ Mgallegos \ DecimaAccounting \ System \ Repositories \ AccountChartType \ EloquentAccountChartType ( new AccountChartType ( ) ) ; } ) ; }
Register an account chart type interface instance .
25,409
protected function registerSettingInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\Setting\SettingInterface' , function ( $ app ) { $ AuthenticationManager = $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) ; return new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ Setting \ EloquentSetting ( new Setting ( ) , $ AuthenticationManager -> getCurrentUserOrganizationConnection ( ) ) ; } ) ; }
Register a setting interface instance .
25,410
protected function registerAccountTypeInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\AccountType\AccountTypeInterface' , function ( $ app ) { $ AuthenticationManager = $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) ; return new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ AccountType \ EloquentAccountType ( new AccountType ( ) , $ AuthenticationManager -> getCurrentUserOrganizationConnection ( ) ) ; } ) ; }
Register an account type interface instance .
25,411
protected function registerPeriodInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\Period\PeriodInterface' , function ( $ app ) { $ AuthenticationManager = $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) ; return new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ Period \ EloquentPeriod ( new Period ( ) , $ app [ 'db' ] , $ AuthenticationManager -> getCurrentUserOrganizationConnection ( ) ) ; } ) ; }
Register a period interface instance .
25,412
protected function registerFiscalYearInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\FiscalYear\FiscalYearInterface' , function ( $ app ) { $ AuthenticationManager = $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) ; return new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ FiscalYear \ EloquentFiscalYear ( new FiscalYear ( ) , $ AuthenticationManager -> getCurrentUserOrganizationConnection ( ) ) ; } ) ; }
Register a fiscal year interface instance .
25,413
protected function registerAccountInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\Account\AccountInterface' , function ( $ app ) { $ AuthenticationManager = $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) ; return new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ Account \ EloquentAccount ( new Account ( ) , $ AuthenticationManager -> getCurrentUserOrganizationConnection ( ) ) ; } ) ; }
Register an account interface instance .
25,414
protected function registerSystemAccountInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\System\Repositories\Account\AccountInterface' , function ( ) { return new \ Mgallegos \ DecimaAccounting \ System \ Repositories \ Account \ EloquentAccount ( new SystemAccount ( ) ) ; } ) ; }
Register a system account interface instance .
25,415
protected function registerCostCenterInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\CostCenter\CostCenterInterface' , function ( $ app ) { $ AuthenticationManager = $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) ; return new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ CostCenter \ EloquentCostCenter ( new CostCenter ( ) , $ AuthenticationManager -> getCurrentUserOrganizationConnection ( ) ) ; } ) ; }
Register a cost center interface instance .
25,416
protected function registerDocumentTypeInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\DocumentType\DocumentTypeInterface' , function ( $ app ) { $ AuthenticationManager = $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) ; return new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ DocumentType \ EloquentDocumentType ( new DocumentType ( ) , $ AuthenticationManager -> getCurrentUserOrganizationConnection ( ) ) ; } ) ; }
Register a document type interface instance .
25,417
protected function registerClientInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\Client\ClientInterface' , function ( $ app ) { $ AuthenticationManager = $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) ; return new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ Client \ EloquentClient ( new Client ( ) , $ AuthenticationManager -> getCurrentUserOrganizationConnection ( ) ) ; } ) ; }
Register a client interface instance .
25,418
protected function registerSupplierInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\Supplier\SupplierInterface' , function ( $ app ) { $ AuthenticationManager = $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) ; return new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ Supplier \ EloquentSupplier ( new Supplier ( ) , $ AuthenticationManager -> getCurrentUserOrganizationConnection ( ) ) ; } ) ; }
Register a supplier interface instance .
25,419
protected function registerEmployeeInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\Employee\EmployeeInterface' , function ( $ app ) { $ AuthenticationManager = $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) ; return new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ Employee \ EloquentEmployee ( new Employee ( ) , $ AuthenticationManager -> getCurrentUserOrganizationConnection ( ) ) ; } ) ; }
Register a employee interface instance .
25,420
protected function registerApportionmentInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\Apportionment\ApportionmentInterface' , function ( $ app ) { $ AuthenticationManager = $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) ; return new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ Apportionment \ EloquentApportionment ( new Apportionment ( ) , $ AuthenticationManager -> getCurrentUserOrganizationConnection ( ) ) ; } ) ; }
Register a Apportionment interface instance .
25,421
protected function registerApportionmentEntryInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\ApportionmentEntry\ApportionmentEntryInterface' , function ( $ app ) { $ AuthenticationManager = $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) ; return new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ ApportionmentEntry \ EloquentApportionmentEntry ( new ApportionmentEntry ( ) , $ AuthenticationManager -> getCurrentUserOrganizationConnection ( ) ) ; } ) ; }
Register a ApportionmentEntry interface instance .
25,422
protected function registerJournalVoucherInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\JournalVoucher\JournalVoucherInterface' , function ( $ app ) { $ AuthenticationManager = $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) ; return new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ JournalVoucher \ EloquentJournalVoucher ( new JournalVoucher ( ) , $ app [ 'db' ] , $ AuthenticationManager -> getCurrentUserOrganizationConnection ( ) ) ; } ) ; }
Register a journal voucher interface instance .
25,423
protected function registerJournalEntryInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\JournalEntry\JournalEntryInterface' , function ( $ app ) { $ AuthenticationManager = $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) ; return new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ JournalEntry \ EloquentJournalEntry ( new JournalEntry ( ) , $ app [ 'db' ] , $ AuthenticationManager -> getCurrentUserOrganizationConnection ( ) ) ; } ) ; }
Register a journal entry interface instance .
25,424
protected function registerSettingManagementInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Services\SettingManagement\SettingManagementInterface' , function ( $ app ) { return new SettingManager ( $ app -> make ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\Setting\SettingInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\System\Repositories\AccountChartType\AccountChartTypeInterface' ) , $ app -> make ( 'App\Kwaai\System\Repositories\Currency\CurrencyInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\AccountType\AccountTypeInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\System\Repositories\AccountType\AccountTypeInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\Period\PeriodInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\FiscalYear\FiscalYearInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\Account\AccountInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\System\Repositories\Account\AccountInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\VoucherType\VoucherTypeInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\System\Repositories\VoucherType\VoucherTypeInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\CostCenter\CostCenterInterface' ) , $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) , $ app -> make ( 'App\Kwaai\Security\Services\JournalManagement\JournalManagementInterface' ) , $ app -> make ( 'App\Kwaai\Security\Repositories\Journal\JournalInterface' ) , $ app [ 'db' ] , $ app [ 'translator' ] , $ app [ 'config' ] ) ; } ) ; }
Register a setting management interface instance .
25,425
protected function registerPeriodManagementInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Services\PeriodManagement\PeriodManagementInterface' , function ( $ app ) { return new PeriodManager ( $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) , $ app -> make ( 'App\Kwaai\Security\Services\JournalManagement\JournalManagementInterface' ) , $ app -> make ( 'App\Kwaai\Security\Repositories\Journal\JournalInterface' ) , new \ Mgallegos \ LaravelJqgrid \ Encoders \ JqGridJsonEncoder ( $ app -> make ( 'excel' ) ) , new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ Period \ EloquentPeriodGridRepository ( $ app [ 'db' ] , $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) , $ app [ 'translator' ] ) , $ app -> make ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\Period\PeriodInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\JournalVoucher\JournalVoucherInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\FiscalYear\FiscalYearInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\Setting\SettingInterface' ) , new Carbon ( ) , $ app [ 'db' ] , $ app [ 'translator' ] , $ app [ 'config' ] ) ; } ) ; }
Register a period management interface instance .
25,426
protected function registerFiscalYearManagementInterface ( ) { $ this -> app -> bind ( 'Mgallegos\DecimaAccounting\Accounting\Services\FiscalYearManagement\FiscalYearManagementInterface' , function ( $ app ) { return new FiscalYearManager ( $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) , $ app -> make ( 'App\Kwaai\Security\Services\JournalManagement\JournalManagementInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\Accounting\Services\JournalManagement\JournalManagementInterface' ) , $ app -> make ( 'App\Kwaai\Security\Repositories\Journal\JournalInterface' ) , new \ Mgallegos \ LaravelJqgrid \ Encoders \ JqGridJsonEncoder ( $ app -> make ( 'excel' ) ) , new \ Mgallegos \ DecimaAccounting \ Accounting \ Repositories \ FiscalYear \ EloquentFiscalYearGridRepository ( $ app [ 'db' ] , $ app -> make ( 'App\Kwaai\Security\Services\AuthenticationManagement\AuthenticationManagementInterface' ) , $ app [ 'translator' ] ) , $ app -> make ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\FiscalYear\FiscalYearInterface' ) , $ app -> make ( 'Mgallegos\DecimaAccounting\Accounting\Repositories\JournalEntry\JournalEntryInterface' ) , new Carbon ( ) , $ app [ 'db' ] , $ app [ 'translator' ] , $ app [ 'config' ] ) ; } ) ; }
Register a Fiscal Year management interface instance .
25,427
public function getRoot ( ) { $ next_parent = $ this -> getParent ( ) ; $ parent = null ; while ( $ next_parent ) { $ parent = $ next_parent ; $ next_parent = $ parent -> getParent ( ) ; } return $ parent ? $ parent : $ this ; }
Returns the type s root - parent if it has one .
25,428
public function getAttributes ( array $ attribute_names = [ ] , array $ types = [ ] ) { $ attribute_map = [ ] ; if ( empty ( $ attribute_names ) ) { $ attribute_map = $ this -> attribute_map -> getItems ( ) ; } else { foreach ( $ attribute_names as $ attribute_name ) { $ attribute_map [ $ attribute_name ] = $ this -> getAttribute ( $ attribute_name ) ; } } if ( ! empty ( $ types ) ) { $ attribute_map = array_filter ( $ attribute_map , function ( $ attribute ) use ( $ types ) { return in_array ( get_class ( $ attribute ) , $ types ) ; } ) ; } return new AttributeMap ( $ attribute_map ) ; }
Returns the type s attribute collection .
25,429
public function getAttribute ( $ name ) { if ( mb_strpos ( $ name , '.' ) ) { return $ this -> getAttributeByPath ( $ name ) ; } if ( $ this -> attribute_map -> hasKey ( $ name ) ) { return $ this -> attribute_map -> getItem ( $ name ) ; } else { throw new RuntimeException ( 'Type has no attribute: ' . $ name ) ; } }
Returns a certain type attribute by name .
25,430
public function createEntity ( array $ data = [ ] , EntityInterface $ parent_entity = null , $ apply_default_values = false ) { $ implementor = $ this -> getEntityImplementor ( ) ; if ( ! class_exists ( $ implementor , true ) ) { throw new InvalidTypeException ( "Unable to resolve the given entity implementor '$implementor' upon entity creation request." ) ; } return new $ implementor ( $ this , $ data , $ parent_entity , $ apply_default_values ) ; }
Creates a new EntityInterface instance .
25,431
protected function writeCapped ( array $ record ) { if ( $ this -> redisClient instanceof \ Redis ) { $ this -> redisClient -> multi ( ) -> rpush ( $ this -> redisKey , $ record [ "formatted" ] ) -> ltrim ( $ this -> redisKey , - $ this -> capSize , - 1 ) -> exec ( ) ; } else { $ redisKey = $ this -> redisKey ; $ capSize = $ this -> capSize ; $ this -> redisClient -> transaction ( function ( $ tx ) use ( $ record , $ redisKey , $ capSize ) { $ tx -> rpush ( $ redisKey , $ record [ "formatted" ] ) ; $ tx -> ltrim ( $ redisKey , - $ capSize , - 1 ) ; } ) ; } }
Write and cap the collection Writes the record to the redis list and caps its
25,432
public function sendBill ( $ bill , callable $ onSuccess , callable $ onFailure ) { if ( $ bill === false ) { return ; } $ currencyEntry = new CurrencyEntry ( ) ; $ currencyEntry -> setBill ( $ bill ) ; $ currencyEntry -> setSuccessCallback ( $ onSuccess ) ; $ currencyEntry -> setFailureCallback ( $ onFailure ) ; $ this -> currencyPlugin -> sendBill ( $ currencyEntry ) ; }
Send bill to login Server needs to have in - game currency for sending a bill .
25,433
public function createBill ( $ login , $ amount , $ receiver , $ message ) { $ currencyEntry = new Gamecurrency ( ) ; $ currencyEntry -> setAmount ( $ amount ) ; $ currencyEntry -> setSenderlogin ( $ login ) ; $ currencyEntry -> setReceiverlogin ( $ receiver ) ; $ currencyEntry -> setMessage ( $ message ) ; $ currencyEntry -> setDatetime ( new \ DateTime ( ) ) ; try { $ currencyEntry -> save ( ) ; return $ currencyEntry ; } catch ( \ Exception $ e ) { $ this -> logger -> error ( "Error while creating bill" , [ "exception" => $ e ] ) ; $ this -> console -> write ( '$f00 Fail.' , true ) ; return false ; } }
Create a bill for sending it forward
25,434
public function goToNextStep ( array $ data , ReservationForm $ form ) { $ reservation = $ form -> getReservation ( ) ; foreach ( $ data [ 'Attendee' ] as $ attendeeID => $ attendeeData ) { $ attendee = Attendee :: get ( ) -> byID ( $ attendeeID ) ; foreach ( $ attendeeData as $ field => $ value ) { if ( is_int ( $ field ) ) { $ attendee -> Fields ( ) -> add ( $ field , array ( 'Value' => $ value ) ) ; } else { $ attendee -> setField ( $ field , $ value ) ; } } $ attendee -> write ( ) ; if ( isset ( $ attendeeData [ 'Main' ] ) && ( bool ) $ attendeeData [ 'Main' ] ) { $ reservation -> setMainContact ( $ attendeeID ) ; } } $ reservation -> PriceModifiers ( ) -> add ( TaxModifier :: findOrMake ( $ reservation ) ) ; $ reservation -> calculateTotal ( ) ; $ reservation -> write ( ) ; $ this -> extend ( 'beforeNextStep' , $ data , $ form ) ; return $ this -> nextStep ( ) ; }
Finish the registration and continue to checkout
25,435
function validateRequest ( $ result ) { $ statusCodes = array ( "200" => "" , "304" => "Not Modified" , "400" => "Bad Request" , "401" => "Unauthorized: Authentication credentials were missing or incorrect" , "403" => "Forbidden: The request is understood, but it has been refused" , "404" => "Not Found" , "406" => "Not Acceptable" , "420" => "Enhance Your Calm" , "500" => "Internal Server Error" , "502" => "Bad Gateway" , "503" => "Service Unavailable" ) ; if ( array_key_exists ( $ this -> lastStatusCode ( ) , $ statusCodes ) ) return $ this -> lastStatusCode ( ) . " " . $ statusCodes [ $ this -> lastStatusCode ( ) ] ; else { return $ this -> lastStatusCode ( ) . " Unknow" ; } }
It is a good idea to implement this also
25,436
public function addChild ( $ class , $ id , $ label , $ permission , $ options = [ ] ) { if ( is_string ( $ id ) ) { $ id = explode ( '/' , $ id ) ; } if ( count ( $ id ) == 1 ) { if ( isset ( $ this -> childItems [ $ id [ 0 ] ] ) ) { return $ this -> childItems [ $ id [ 0 ] ] ; } $ item = $ this -> itemBuilder -> create ( $ class , $ id [ 0 ] , $ this -> getPath ( ) . '/' . $ id [ 0 ] , $ label , $ permission , $ options ) ; $ this -> childItems [ $ id [ 0 ] ] = $ item ; return $ item ; } $ parent = array_splice ( $ id , 0 , count ( $ id ) - 1 ) ; return $ this -> getChild ( $ parent ) -> addChild ( $ class , $ id , $ label , $ permission , $ options ) ; }
Add a new child element to the parent node .
25,437
public function getChild ( $ path ) { if ( is_string ( $ path ) ) { $ path = explode ( '/' , $ path ) ; } $ remaining = array_splice ( $ path , 1 , count ( $ path ) - 1 ) ; foreach ( $ this -> childItems as $ childItem ) { if ( $ childItem -> getId ( ) == $ path [ 0 ] ) { if ( empty ( $ remaining ) ) { return $ childItem ; } elseif ( $ childItem instanceof ParentItem ) { return $ childItem -> getChild ( $ remaining ) ; } else { return null ; } } } return null ; }
Get child element from path py searching recursiveley .
25,438
public function isVisibleFor ( $ login ) { $ personalVisibility = parent :: isVisibleFor ( $ login ) ; if ( ! $ personalVisibility ) { return $ personalVisibility ; } foreach ( $ this -> getChilds ( ) as $ childItem ) { if ( $ childItem -> isVisibleFor ( $ login ) ) { return true ; } } return false ; }
Check if menu is visible and at least one children is visible .
25,439
public static function hasValidLength ( $ value ) { $ value = ( int ) $ value ; $ length = strlen ( $ value ) ; return ! ( $ length < 9 || $ length > 13 ) ; }
Check if length of given ean makes sense .
25,440
public static function toIsbn10 ( $ ean , $ onError = null ) { $ ean = preg_replace ( '/[^0-9]/' , '' , $ ean ) ; if ( ! preg_match ( '/^978(\d{9})\d?$/' , $ ean , $ found ) ) { return $ onError ; } $ isbn = $ found [ 1 ] ; $ isbn = static :: withCheckDigitForIsbn10 ( $ isbn ) ; return $ isbn ? : $ onError ; }
Convert isbn13 to isbn10 .
25,441
public function prepareRules ( ) { switch ( self :: baseClassName ( $ this -> input ) ) { case 'FakturaVydana' : case 'Banka' : switch ( self :: baseClassName ( $ this -> output ) ) { case 'FakturaVydana' : $ this -> rules = array_combine ( $ this -> commonItems ( ) , $ this -> commonItems ( ) ) ; unset ( $ this -> rules [ 'stavUhrK' ] ) ; unset ( $ this -> rules [ 'datUcto' ] ) ; unset ( $ this -> rules [ 'datUcto' ] ) ; foreach ( array_keys ( $ this -> output -> getData ( ) ) as $ colname ) { unset ( $ this -> rules [ $ colname ] ) ; } if ( $ this -> input -> getDataValue ( 'typDokl' ) != $ this -> output -> getDataValue ( 'typDokl' ) ) { unset ( $ this -> rules [ 'rada' ] ) ; } foreach ( $ this -> rules as $ rule ) { if ( preg_match ( '/^sum/' , $ rule ) ) { unset ( $ this -> rules [ $ rule ] ) ; } } $ polozkyDokladu = new \ FlexiPeeHP \ FakturaVydanaPolozka ( ) ; $ itemColnames = array_keys ( $ polozkyDokladu -> getColumnsInfo ( ) ) ; $ this -> rules [ 'polozkyFaktury' ] = self :: removeRoColumns ( array_combine ( $ itemColnames , $ itemColnames ) , $ polozkyDokladu ) ; break ; default : throw new \ Ease \ Exception ( sprintf ( _ ( 'Unsupported Source document type %s' ) , get_class ( $ this -> output ) ) ) ; break ; } break ; default : throw new \ Ease \ Exception ( sprintf ( _ ( 'Unsupported Source document type %s' ) , get_class ( $ this -> input ) ) ) ; break ; } }
Prepare conversion rules
25,442
public function convertDocument ( $ keepId = false , $ addExtId = false , $ keepCode = false , $ handleAccountig = false ) { if ( $ handleAccountig === false ) { unset ( $ this -> rules [ 'ucetni' ] ) ; } $ this -> convertItems ( $ keepId , $ addExtId , $ keepCode , $ handleAccountig ) ; }
Convert FlexiBee document
25,443
public function convertSubitems ( $ columnToTake , $ keepId = false , $ keepCode = false , $ keepAccountig = false ) { $ subitemRules = $ this -> rules [ $ columnToTake ] ; if ( self :: isAssoc ( $ this -> input -> data [ $ columnToTake ] ) ) { $ sourceData = [ $ this -> input -> data [ $ columnToTake ] ] ; } else { $ sourceData = $ this -> input -> getDataValue ( $ columnToTake ) ; } $ typUcOp = $ this -> input -> getDataValue ( 'typUcOp' ) ; foreach ( $ sourceData as $ subItemData ) { foreach ( array_keys ( $ subItemData ) as $ subitemColumn ) { if ( ! array_key_exists ( $ subitemColumn , $ subitemRules ) ) { unset ( $ subItemData [ $ subitemColumn ] ) ; } } if ( $ keepAccountig && array_key_exists ( 'ucetni' , $ subItemData ) && array_key_exists ( 'ucetni' , $ this -> output -> getData ( ) ) ) { $ subItemData [ 'ucetni' ] = $ this -> output -> getDataValue ( 'ucetni' ) ; } else { unset ( $ subItemData [ 'ucetni' ] ) ; } if ( $ typUcOp ) { $ subItemData [ 'typUcOp' ] = $ typUcOp ; } else { unset ( $ subItemData [ 'typUcOp' ] ) ; } if ( $ keepCode === false ) { unset ( $ subItemData [ 'kod' ] ) ; } if ( $ keepId === false ) { unset ( $ subItemData [ 'id' ] ) ; unset ( $ subItemData [ 'external-ids' ] ) ; } $ this -> output -> addArrayToBranch ( $ subItemData ) ; } }
Convert FlexiBee documnet s subitems
25,444
public function convertItems ( $ keepId = false , $ addExtId = true , $ keepCode = false , $ handleAccounting = false ) { if ( $ keepCode === false ) { unset ( $ this -> rules [ 'kod' ] ) ; } if ( $ keepId === false ) { unset ( $ this -> rules [ 'id' ] ) ; } foreach ( self :: removeRoColumns ( $ this -> rules , $ this -> output ) as $ columnToTake => $ subitemColumns ) { if ( is_array ( $ subitemColumns ) ) { if ( ! empty ( $ this -> input -> getSubItems ( ) ) ) { $ this -> convertSubitems ( $ columnToTake , $ keepId , $ keepCode , $ handleAccounting ) ; } } else { $ this -> output -> setDataValue ( $ columnToTake , $ this -> input -> getDataValue ( $ columnToTake ) ) ; } } if ( $ addExtId ) { $ this -> output -> setDataValue ( 'id' , 'ext:src:' . $ this -> input -> getEvidence ( ) . ':' . $ this -> input -> getMyKey ( ) ) ; } }
Convert document items
25,445
public static function removeRoColumns ( array $ rules , $ engine ) { foreach ( $ rules as $ index => $ subrules ) { if ( is_array ( $ subrules ) ) { $ eback = $ engine -> getEvidence ( ) ; $ engine -> setEvidence ( $ engine -> getEvidence ( ) . '-polozka' ) ; $ rules [ $ index ] = self :: removeRoColumns ( $ subrules , $ engine ) ; $ engine -> setEvidence ( $ eback ) ; } else { $ columnInfo = $ engine -> getColumnInfo ( $ subrules ) ; if ( $ columnInfo [ 'isWritable' ] == 'false' ) { unset ( $ rules [ $ index ] ) ; } } } return $ rules ; }
Returns only writable columns
25,446
public function commonItems ( ) { return array_intersect ( array_keys ( $ this -> input -> getColumnsInfo ( ) ) , array_keys ( $ this -> output -> getColumnsInfo ( ) ) ) ; }
Return itemes that same on both sides
25,447
protected function doBuild ( $ user , $ isApi = false ) { $ this -> register ( $ user , $ isApi ) ; $ this -> container -> setAlias ( $ this -> alias ( $ user , $ isApi ) , $ this -> definition ( $ user , $ isApi ) ) ; return $ this -> container ; }
Wraps the service registration and the alias addtion .
25,448
final public function createVisitors ( int $ flags = 0 ) : VisitorInterface { $ flag = function ( int $ needle ) use ( $ flags ) { return ( $ needle & $ flags ) == $ needle ; } ; $ errorObj = new ErrorObject ; $ container = new VisitorContainer ( $ errorObj ) ; if ( ! $ flag ( self :: VISITOR_IGNORE_BASIC_VALIDATION ) ) { $ container -> addVisitor ( new NumberVisitor ( $ errorObj ) ) ; $ container -> addVisitor ( new TextVisitor ( $ errorObj ) ) ; } if ( ! $ flag ( self :: VISITOR_IGNORE_MESSAGES ) ) { $ container -> addVisitor ( new MessageVisitor ( $ errorObj ) ) ; } if ( ! $ flag ( self :: VISITOR_IGNORE_DATES ) ) { $ container -> addVisitor ( new DateVisitor ( $ errorObj ) ) ; } if ( ! $ flag ( self :: VISITOR_IGNORE_ACCOUNTS ) ) { $ container -> addVisitor ( new AccountVisitor ( $ errorObj , new DelegatingFactory ( new AccountFactory , new BankgiroFactory ) , new BankgiroFactory ) ) ; } if ( ! $ flag ( self :: VISITOR_IGNORE_AMOUNTS ) ) { $ container -> addVisitor ( new AmountVisitor ( $ errorObj ) ) ; } if ( ! $ flag ( self :: VISITOR_IGNORE_IDS ) ) { $ container -> addVisitor ( new StateIdVisitor ( $ errorObj , new OrganizationIdFactory , new PersonalIdFactory ( new CoordinationIdFactory ( new NullIdFactory ) ) ) ) ; } if ( ! $ flag ( self :: VISITOR_IGNORE_STRICT_VALIDATION ) ) { $ container -> addVisitor ( new PaymentVisitor ( $ errorObj ) ) ; $ container -> addVisitor ( new PayeeVisitor ( $ errorObj ) ) ; $ container -> addVisitor ( new CountingVisitor ( $ errorObj ) ) ; $ container -> addVisitor ( new SummaryVisitor ( $ errorObj ) ) ; } return $ container ; }
Create the standard set of visitors used when processing a parse tree
25,449
public function listAction ( ) { $ siteConfig = $ this -> getServiceLocator ( ) -> get ( 'config' ) ; $ siteConfig = $ siteConfig [ 'site' ] [ 'MelisDemoCms' ] ; $ siteDatas = $ siteConfig [ 'datas' ] ; $ listNewsPluginView = $ this -> MelisCmsNewsListNewsPlugin ( ) ; $ listNewsParameters = array ( 'template_path' => 'MelisDemoCms/plugin/news-list' , 'pageId' => $ this -> idPage , 'pageIdNews' => $ siteDatas [ 'news_details_page_id' ] , 'pagination' => array ( 'nbPerPage' => 6 ) , 'filter' => array ( 'column' => 'cnews_publish_date' , 'order' => 'DESC' , 'unpublish_filter' => true , 'site_id' => $ siteDatas [ 'site_id' ] , ) ) ; $ this -> view -> addChild ( $ listNewsPluginView -> render ( $ listNewsParameters ) , 'listNews' ) ; $ this -> view -> setVariable ( 'renderMode' , $ this -> renderMode ) ; $ this -> view -> setVariable ( 'idPage' , $ this -> idPage ) ; return $ this -> view ; }
This method will render the list of news
25,450
public function detailsAction ( ) { $ siteConfig = $ this -> getServiceLocator ( ) -> get ( 'config' ) ; $ siteConfig = $ siteConfig [ 'site' ] [ 'MelisDemoCms' ] ; $ siteDatas = $ siteConfig [ 'datas' ] ; $ dateMax = date ( "Y-m-d H:i:s" , strtotime ( "now" ) ) ; $ listNewsPluginView = $ this -> MelisCmsNewsShowNewsPlugin ( ) ; $ listNewsParameters = array ( 'id' => 'newsDetails' , 'template_path' => 'MelisDemoCms/plugin/news-details' , ) ; $ this -> view -> addChild ( $ listNewsPluginView -> render ( $ listNewsParameters ) , 'newsDetails' ) ; $ latestNewsPluginView = $ this -> MelisCmsNewsLatestNewsPlugin ( ) ; $ latestNewsParameters = array ( 'template_path' => 'MelisDemoCms/plugin/latest-news' , 'pageIdNews' => $ siteDatas [ 'news_details_page_id' ] , 'filter' => array ( 'column' => 'cnews_publish_date' , 'order' => 'DESC' , 'limit' => 10 , 'unpublish_filter' => true , 'date_max' => null , 'site_id' => $ siteDatas [ 'site_id' ] , ) ) ; $ this -> view -> addChild ( $ latestNewsPluginView -> render ( $ latestNewsParameters ) , 'latestNews' ) ; $ this -> view -> setVariable ( 'renderMode' , $ this -> renderMode ) ; $ this -> view -> setVariable ( 'idPage' , $ this -> idPage ) ; return $ this -> view ; }
This methos will render the Details of a single News
25,451
public function preFlush ( PreFlushEventArgs $ event ) { $ entityManager = $ event -> getEntityManager ( ) ; $ uow = $ entityManager -> getUnitOfWork ( ) ; foreach ( $ uow -> getIdentityMap ( ) as $ class => $ entities ) { foreach ( $ entities as $ entity ) { if ( $ entity instanceof DeletableInterface ) { if ( $ entity -> isDeleted ( ) ) { $ entityManager -> remove ( $ entity ) ; } } } } }
Remove entities marked as deleted
25,452
private function initializeTcpdf ( ) { if ( defined ( 'K_TCPDF_EXTERNAL_CONFIG' ) ) { return ; } define ( 'K_TCPDF_EXTERNAL_CONFIG' , true ) ; define ( 'K_PATH_MAIN' , $ this -> ensurePathEndsWithSlash ( $ this -> container -> getParameter ( 'orkestra.pdf.tcpdf.root_dir' ) ) ) ; define ( 'K_PATH_URL' , $ this -> ensurePathEndsWithSlash ( $ this -> container -> getParameter ( 'orkestra.pdf.tcpdf.root_dir' ) ) ) ; define ( 'K_PATH_FONTS' , $ this -> ensurePathEndsWithSlash ( $ this -> container -> getParameter ( 'orkestra.pdf.tcpdf.fonts_dir' ) ) ) ; define ( 'K_PATH_CACHE' , $ this -> ensurePathEndsWithSlash ( $ this -> container -> getParameter ( 'orkestra.pdf.cache_dir' ) ) ) ; define ( 'K_PATH_URL_CACHE' , $ this -> ensurePathEndsWithSlash ( $ this -> container -> getParameter ( 'orkestra.pdf.cache_dir' ) ) ) ; define ( 'K_PATH_IMAGES' , $ this -> ensurePathEndsWithSlash ( $ this -> container -> getParameter ( 'orkestra.pdf.tcpdf.image_dir' ) ) ) ; define ( 'K_BLANK_IMAGE' , K_PATH_IMAGES . '_blank.png' ) ; define ( 'K_CELL_HEIGHT_RATIO' , 1.25 ) ; define ( 'K_SMALL_RATIO' , 2 / 3 ) ; define ( 'K_THAI_TOPCHARS' , true ) ; define ( 'K_TCPDF_CALLS_IN_HTML' , false ) ; }
Replicates the tcpdf_config . php file
25,453
public function getDsn ( ) : string { $ _dsn = $ this -> getDriver ( ) . ':' . 'host=' . $ this -> getHost ( ) . ( $ this -> getPort ( ) != 0 ? ';port=' . $ this -> getPort ( ) : '' ) . ';dbname=' . $ this -> getSchema ( ) . ';charset=' . $ this -> getCharset ( ) ; $ this -> setDsn ( $ _dsn ) ; return $ _dsn ; }
Get DSN - MySql formatting
25,454
private function isAfterOpeningBracket ( FoundClass $ c ) { for ( $ k = $ c -> from ; $ k >= 0 ; $ k -- ) { if ( is_string ( $ this -> file -> tokens [ $ k ] ) && $ this -> file -> tokens [ $ k ] === '{' ) { return true ; } } return false ; }
Returns if given token is after a opening bracket
25,455
public function checkProvider ( $ provider ) { if ( ( $ prv = $ this -> payload ( ) -> get ( 'prv' ) ) === null ) { return true ; } return $ this -> hashProvider ( $ provider ) === $ prv ; }
Check if the provider matches the one saved in the token .
25,456
public function _encodeEntities ( $ string ) { $ string = mb_convert_encoding ( $ string , 'UTF-32' , 'UTF-8' ) ; $ t = unpack ( "N*" , $ string ) ; $ t = array_map ( function ( $ n ) { return "&#$n;" ; } , $ t ) ; return implode ( "" , $ t ) ; }
Returns a string converted to html entities .
25,457
private function hydrateArray ( $ array , $ group , $ version ) { foreach ( $ array as $ key => $ value ) { $ this -> hydrate ( $ value , $ group , $ version ) ; } return $ array ; }
Hydrate an array .
25,458
private function hydrateEntity ( EntityInterface $ entity , $ group , $ version ) { $ entity -> setEntityGroup ( $ group ) ; $ entity -> setAPIVersion ( $ version ) ; $ metadata = $ this -> metadataFactory -> getMetadataForClass ( \ get_class ( $ entity ) ) ; foreach ( $ metadata -> propertyMetadata as $ property ) { if ( 'array' === $ property -> type [ 'name' ] ) { $ array = $ property -> getValue ( $ entity ) ; if ( \ is_array ( $ array ) && \ count ( $ array ) > 0 ) { $ first = \ array_values ( $ array ) [ 0 ] ; if ( ( \ is_object ( $ first ) || \ is_array ( $ first ) ) ) { $ this -> hydrateArray ( $ array , $ group , $ version ) ; } } } elseif ( ( $ object = $ property -> getValue ( $ entity ) ) instanceof EntityInterface ) { $ this -> hydrateEntity ( $ object , $ group , $ version ) ; } } return $ entity ; }
Hydrate an entity .
25,459
public static function request ( $ arg_endpoint , $ arg_method , array $ arg_data = array ( ) , array $ arg_headers = array ( ) ) { $ return = array ( ) ; $ headers = array ( 'Accept: application/json' , 'DUE-API-KEY: ' . Due :: getApiKey ( ) , 'DUE-PLATFORM-ID: ' . Due :: getPlatformId ( ) , ) ; if ( $ arg_method == APIRequests :: METHOD_PUT ) { $ headers [ ] = 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' ; } $ headers = array_merge ( $ headers , $ arg_headers ) ; $ full_url = Due :: getRootPath ( ) . $ arg_endpoint ; $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ full_url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_CUSTOMREQUEST , $ arg_method ) ; curl_setopt ( $ ch , CURLOPT_HEADER , true ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ headers ) ; if ( ! empty ( $ arg_data ) ) { curl_setopt ( $ ch , CURLOPT_POSTFIELDS , http_build_query ( $ arg_data ) ) ; } $ response = curl_exec ( $ ch ) ; $ err = curl_error ( $ ch ) ; if ( ! $ err ) { $ header_size = curl_getinfo ( $ ch , CURLINFO_HEADER_SIZE ) ; $ headers = substr ( $ response , 0 , $ header_size ) ; $ body = substr ( $ response , $ header_size ) ; $ return [ 'headers' ] = self :: headersToArray ( $ headers ) ; $ return [ 'body' ] = json_decode ( $ body , true ) ; if ( ! empty ( $ return [ 'body' ] [ 'errors' ] [ 0 ] ) ) { $ api_error = $ return [ 'body' ] [ 'errors' ] [ 0 ] ; $ message = ( empty ( $ api_error [ 'message' ] ) ? '' : $ api_error [ 'message' ] ) ; $ code = ( empty ( $ api_error [ 'code' ] ) ? 0 : $ api_error [ 'code' ] ) ; throw new \ Exception ( $ message , $ code ) ; } } else { throw new \ Exception ( $ err ) ; } return $ return ; }
Due API Request
25,460
public static function headersToArray ( $ header_text ) { $ headers = array ( ) ; foreach ( explode ( "\r\n" , $ header_text ) as $ i => $ line ) if ( $ i === 0 ) $ headers [ 'http_code' ] = $ line ; else { if ( ! empty ( $ line ) && strpos ( $ line , ':' ) !== false ) { list ( $ key , $ value ) = explode ( ': ' , $ line ) ; $ headers [ 'headers' ] [ ] = array ( 'key' => $ key , 'value' => $ value , ) ; } } return $ headers ; }
Convert Header data to array
25,461
protected function loadFactory ( ? array $ params = [ ] ) { if ( \ is_array ( $ params ) && ! empty ( $ params [ 'class' ] ) && \ class_exists ( $ params [ 'class' ] ) ) { $ factory = new $ params [ 'class' ] ( $ params [ 'options' ] ?? [ ] ) ; $ this -> getLogger ( ) -> debug ( 'Factory created' , [ 'factory' => $ factory ] ) ; return $ factory ; } else { $ this -> getLogger ( ) -> error ( 'Factory not found' , [ 'params' => $ params ] ) ; } return null ; }
Loads a Factory class
25,462
public function setCookie ( string $ name , string $ value = null , int $ expire = 0 , string $ path = '' , string $ domain = '' , bool $ secure = false , bool $ httpOnly = false ) { if ( \ array_key_exists ( $ name , $ this -> cookies ) && \ is_null ( $ value ) ) { $ this -> cookies = \ array_diff_key ( $ this -> cookies , [ $ name => '' ] ) ; } else { $ this -> cookies [ $ name ] = [ 'name' => $ name , 'value' => $ value , 'expire' => $ expire , 'path' => $ path , 'domain' => $ domain , 'secure' => $ secure , 'httpOnly' => $ httpOnly ] ; } return true ; }
Set a cookie for the next response
25,463
public function sendResponse ( ) { \ http_response_code ( $ this -> getResponse ( ) -> getStatusCode ( ) ) ; foreach ( $ this -> getResponse ( ) -> getHeaders ( ) as $ header => $ value ) { if ( \ is_array ( $ value ) ) { $ values = \ implode ( ';' , $ value ) ; } else { $ values = $ value ; } \ header ( $ header . ': ' . $ values ) ; } if ( \ function_exists ( 'header_remove' ) ) \ header_remove ( 'x-powered-by' ) ; foreach ( $ this -> cookies as $ cookie ) { \ setCookie ( $ cookie [ 'name' ] , $ cookie [ 'value' ] , $ cookie [ 'expire' ] ?? 0 , $ cookie [ 'path' ] ?? '' , $ cookie [ 'domain' ] ?? '' , $ cookie [ 'secure' ] ?? false , $ cookie [ 'httponly' ] ?? false ) ; } if ( ! empty ( $ this -> responseFile ) ) { if ( \ file_exists ( $ this -> responseFile ) ) { $ this -> getLogger ( ) -> debug ( 'Sending file' , [ 'code' => $ this -> getResponse ( ) -> getStatusCode ( ) , 'headers' => $ this -> getResponse ( ) -> getHeaders ( ) , 'file' => $ this -> responseFile ] ) ; \ readfile ( $ this -> responseFile ) ; } else { $ this -> getLogger ( ) -> warning ( 'File not found' , [ 'file' => $ this -> responseFile ] ) ; \ response ( '' , 404 ) ; \ http_response_code ( 404 ) ; } } else { $ body = ( string ) $ this -> response -> getBody ( ) ; $ this -> getLogger ( ) -> debug ( 'Sending body' , [ 'code' => $ this -> getResponse ( ) -> getStatusCode ( ) , 'headers' => $ this -> getResponse ( ) -> getHeaders ( ) , 'size' => \ strlen ( $ body ) ] ) ; echo $ body ; } return $ this ; }
Send Response back to client
25,464
public function updateTotal ( & $ total ) { $ rate = ( float ) self :: config ( ) -> get ( 'tax_rate' ) / 100 ; $ tax = $ total * $ rate ; $ this -> setPriceModification ( $ tax ) ; if ( ! ( bool ) self :: config ( ) -> get ( 'inclusive' ) ) { $ total += $ tax ; } }
Update the total if the tax is not inclusive the total gets altered
25,465
public function getTableTitle ( ) { $ rate = _t ( 'TaxModifier.TABLE_TITLE' , '{rate}% BTW' , null , array ( 'rate' => ( float ) self :: config ( ) -> get ( 'tax_rate' ) ) ) ; if ( ( bool ) self :: config ( ) -> get ( 'inclusive' ) ) { $ inc = _t ( 'TaxModifier.INCLUSIVE' , '(Incl.)' ) ; $ rate .= " $inc" ; } return $ rate ; }
Show the used tax rate in the table title
25,466
public static function findOrMake ( Reservation $ reservation ) { if ( ! $ modifier = $ reservation -> PriceModifiers ( ) -> find ( 'ClassName' , self :: class ) ) { $ modifier = self :: create ( ) ; $ modifier -> write ( ) ; } return $ modifier ; }
Create a tax modifier if it does not already exists
25,467
public static function doDelete ( $ values , ConnectionInterface $ con = null ) { if ( null === $ con ) { $ con = Propel :: getServiceContainer ( ) -> getWriteConnection ( MapTableMap :: DATABASE_NAME ) ; } if ( $ values instanceof Criteria ) { $ criteria = $ values ; } elseif ( $ values instanceof \ eXpansion \ Bundle \ Maps \ Model \ Map ) { $ criteria = $ values -> buildPkeyCriteria ( ) ; } else { $ criteria = new Criteria ( MapTableMap :: DATABASE_NAME ) ; $ criteria -> add ( MapTableMap :: COL_ID , ( array ) $ values , Criteria :: IN ) ; } $ query = MapQuery :: create ( ) -> mergeWith ( $ criteria ) ; if ( $ values instanceof Criteria ) { MapTableMap :: clearInstancePool ( ) ; } elseif ( ! is_object ( $ values ) ) { foreach ( ( array ) $ values as $ singleval ) { MapTableMap :: removeInstanceFromPool ( $ singleval ) ; } } return $ query -> delete ( $ con ) ; }
Performs a DELETE on the database given a Map or Criteria object OR a primary key value .
25,468
public function getUserData ( ) : FilesystemInterface { if ( $ this -> connectionType == self :: CONNECTION_TYPE_LOCAL ) { return $ this -> getLocalAdapter ( ) ; } else { return $ this -> remoteAdapter ; } }
Get Filesystem adapter for the user data directory of the dedicated server .
25,469
protected function getLocalAdapter ( ) : FilesystemInterface { if ( is_null ( $ this -> localAdapter ) ) { $ dir = $ this -> factory -> getConnection ( ) -> getMapsDirectory ( ) ; $ this -> localAdapter = new \ League \ Flysystem \ Filesystem ( new Local ( $ dir . '/../' ) ) ; } return $ this -> localAdapter ; }
Get local adapter if dedicated is installed on same host .
25,470
protected function isPluginCompatible ( PluginDescription $ plugin , $ enabledPlugins , $ title , $ mode , $ script , Map $ map ) { foreach ( $ plugin -> getParents ( ) as $ parentPluginId ) { if ( ! isset ( $ enabledPlugins [ $ parentPluginId ] ) ) { return false ; } } foreach ( $ plugin -> getDataProviders ( ) as $ dataProvider ) { $ dataProviders = explode ( "|" , $ dataProvider ) ; $ foundOne = false ; foreach ( $ dataProviders as $ provider ) { $ providerId = $ this -> dataProviderManager -> getCompatibleProviderId ( $ provider , $ title , $ mode , $ script , $ map ) ; if ( ! is_null ( $ providerId ) && isset ( $ enabledPlugins [ $ providerId ] ) ) { $ foundOne = true ; break ; } } if ( ! $ foundOne ) { return false ; } } if ( $ plugin -> isIsDataProvider ( ) ) { $ selectedProvider = $ this -> dataProviderManager -> getCompatibleProviderId ( $ plugin -> getDataProviderName ( ) , $ title , $ mode , $ script , $ map ) ; if ( $ plugin -> getPluginId ( ) != $ selectedProvider ) { return false ; } } return true ; }
Check if a plugin is compatible or not .
25,471
protected function enablePlugin ( PluginDescription $ plugin , $ title , $ mode , $ script , Map $ map ) { $ notify = false ; $ plugin -> setIsEnabled ( true ) ; $ pluginService = $ this -> container -> get ( $ plugin -> getPluginId ( ) ) ; if ( ! isset ( $ this -> enabledPlugins [ $ plugin -> getPluginId ( ) ] ) ) { $ notify = true ; } foreach ( $ plugin -> getDataProviders ( ) as $ provider ) { $ dataProviders = explode ( "|" , $ provider ) ; foreach ( $ dataProviders as $ dataProvider ) { $ this -> dataProviderManager -> registerPlugin ( $ dataProvider , $ plugin -> getPluginId ( ) , $ title , $ mode , $ script , $ map ) ; } } $ this -> enabledPlugins [ $ plugin -> getPluginId ( ) ] = $ plugin ; return $ notify ? $ pluginService : null ; }
Enable a certain plugin .
25,472
public function getDomain ( ) { $ uri = $ this -> getServiceLocator ( ) -> get ( 'Application' ) -> getMvcEvent ( ) -> getRequest ( ) -> getUri ( ) ; return sprintf ( '%s://%s' , $ uri -> getScheme ( ) , $ uri -> getHost ( ) ) ; }
Returns the current URL of the page
25,473
public function checkMysqlConnection ( $ host , $ db , $ user , $ pass ) { $ results = array ( ) ; $ isConnected = 0 ; $ isDatabaseExists = 0 ; $ isDatabaseCollationNameValid = 0 ; $ isPassCorrect = 1 ; if ( $ this -> isDomainExists ( $ host ) ) { $ isConnected = 1 ; try { $ dbAdapter = new DbAdapter ( array ( 'driver' => 'Pdo' , 'dsn' => 'mysql:dbname=INFORMATION_SCHEMA;host=' . $ host , 'username' => $ user , 'password' => $ pass , 'driver_options' => array ( PDO :: MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'" ) , ) ) ; $ sql = new Sql ( $ dbAdapter ) ; $ select = $ sql -> select ( ) ; $ select -> from ( 'SCHEMATA' ) ; $ select -> where ( array ( 'SCHEMA_NAME' => $ db ) ) ; $ statement = $ sql -> prepareStatementForSqlObject ( $ select ) ; $ result = $ statement -> execute ( ) ; $ schema = $ result -> current ( ) ; if ( ! empty ( $ schema ) ) { $ isDatabaseExists = 1 ; if ( ! empty ( $ schema [ 'DEFAULT_COLLATION_NAME' ] ) && $ schema [ 'DEFAULT_COLLATION_NAME' ] === 'utf8_general_ci' ) { $ isDatabaseCollationNameValid = 1 ; } } } catch ( \ Exception $ e ) { $ isPassCorrect = 0 ; } } $ results = array ( 'isConnected' => $ isConnected , 'isDatabaseExists' => $ isDatabaseExists , 'isMysqlPasswordCorrect' => $ isPassCorrect , 'isDatabaseCollationNameValid' => $ isDatabaseCollationNameValid , ) ; return $ results ; }
Checks if your MySql is working and if your database is existing
25,474
public function setDbAdapter ( $ config ) { if ( is_array ( $ config ) ) { $ this -> odbAdapter = new DbAdapter ( array_merge ( array ( 'driver' => 'Pdo_Mysql' , 'driver_options' => array ( PDO :: MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'" ) ) , $ config ) ) ; $ config = new \ Zend \ Config \ Config ( $ config , true ) ; $ writer = new \ Zend \ Config \ Writer \ PhpArray ( ) ; $ conf = $ writer -> toString ( $ config ) ; } }
Set s the DB Adapter
25,475
public function executeRawQuery ( $ query ) { $ resultSet = null ; if ( $ this -> odbAdapter ) { if ( ! empty ( $ query ) ) { $ resultSet = $ this -> getDbAdapter ( ) -> query ( $ query , DbAdapter :: QUERY_MODE_EXECUTE ) ; } } return $ resultSet ; }
Executes a raw SQL query
25,476
public function isDbTableExists ( $ tableName ) { $ status = false ; $ resultSet = array ( ) ; $ query = $ this -> executeRawQuery ( "SHOW TABLES LIKE '" . trim ( $ tableName ) . "';" ) ; if ( $ resultSet ) $ resultSet = $ query -> toArray ( ) ; if ( ! empty ( $ resultSet ) ) { $ status = true ; } return $ status ; }
Checks if the table exists or not
25,477
public function importSql ( $ path , $ files = array ( 'setup_structure.sql' ) ) { $ status = false ; $ fImport = null ; if ( file_exists ( $ path ) ) { foreach ( $ files as $ file ) { if ( file_exists ( $ path . $ file ) ) { $ fImport = file_get_contents ( $ path . $ file ) ; $ this -> executeRawQuery ( $ fImport ) ; $ this -> importTableName = array_merge ( $ this -> importTableName , $ this -> getSqlFileTables ( $ path . $ file ) ) ; } } } return $ status ; }
Imports the specified file in the MySql server
25,478
public function getSqlFileTables ( $ path ) { $ tables = array ( ) ; if ( file_exists ( $ path ) ) { $ file = fopen ( $ path , 'r' ) ; $ textToFind = 'CREATE TABLE IF NOT EXISTS ' ; $ found = array ( ) ; $ tables = array ( ) ; while ( ! feof ( $ file ) ) { $ output = fgets ( $ file ) ; $ pos = strrpos ( $ output , $ textToFind ) ; if ( is_int ( $ pos ) ) { $ found [ ] = $ output ; } } foreach ( $ found as $ table ) { $ startPos = strpos ( $ table , '`' ) ; $ lastPos = strrpos ( $ table , '`' ) ; $ tableName = substr ( $ table , $ startPos , $ lastPos ) ; $ tableName = preg_replace ( '/\(|\)/' , '' , $ tableName ) ; $ tables [ ] = trim ( str_replace ( '`' , '' , $ tableName ) ) ; } } return $ tables ; }
Returns all the table names that will be imported
25,479
public function checkEnvironmentVariables ( ) { $ settingsValues = array ( ) ; $ iniSettings = array ( 'memory_limit' , 'max_execution_time' , 'upload_max_filesize' ) ; foreach ( $ iniSettings as $ setting ) { $ settingsValues [ $ setting ] = ini_get ( $ setting ) ; } return $ settingsValues ; }
REturns memory limit execution time and maximum upload size variables
25,480
public function filePermission ( $ path , $ mode = self :: CHMOD_775 ) { $ results = array ( ) ; $ success = 0 ; if ( file_exists ( $ path ) ) { if ( ! is_writable ( $ path ) ) chmod ( $ path , $ mode ) ; if ( ! is_readable ( $ path ) ) chmod ( $ path , $ mode ) ; if ( is_readable ( $ path ) && is_writable ( $ path ) ) $ status = 1 ; } $ results = array ( 'path' => $ path , 'mode' => $ mode , 'success' => $ success ) ; return Json :: encode ( $ results ) ; }
Changes the file permission
25,481
public function replaceFile ( $ old , $ new , array $ content ) { $ oldFileContent = file_get_contents ( $ old ) ; file_put_contents ( $ new , vsprintf ( $ oldFileContent , $ content ) ) ; unlink ( $ old ) ; }
Replaces the old file from the specified path
25,482
public static function guess ( string $ guess ) : ? string { if ( ! \ is_file ( $ guess ) ) { throw new FileNotFoundException ( $ guess ) ; } if ( ! \ is_readable ( $ guess ) ) { throw new AccessDeniedException ( $ guess ) ; } return parent :: guess ( \ pathinfo ( $ guess , \ PATHINFO_EXTENSION ) ) ; }
Guesses the mime type using the file extension .
25,483
public function registerConfig ( ConfigInterface $ config , $ id ) { $ this -> configurationDefinitions [ spl_object_hash ( $ config ) ] = $ config ; $ this -> configurationIds [ spl_object_hash ( $ config ) ] = $ id ; $ this -> configTree -> set ( $ config -> getPath ( ) , $ config ) ; $ config -> setConfigManager ( $ this ) ; }
Register a config to be handled by the config manager .
25,484
public function run ( & $ query , $ model , $ request ) { $ this -> query = $ query ; $ this -> getAttributes ( $ model ) ; $ this -> parseRequest ( $ request ) ; return $ this -> query ( ) ; }
Process the search .
25,485
private function query ( ) { foreach ( $ this -> search_models as $ model_name => $ filters ) { if ( $ model_name === 'self' ) { self :: applySearch ( $ this -> query , $ filters ) ; continue ; } $ this -> query -> whereHas ( $ model_name , function ( $ query ) use ( $ filters ) { self :: applySearch ( $ query , $ filters ) ; } ) ; } return $ this -> query ; }
Run the query .
25,486
public function getAttributes ( $ model ) { $ this -> model = $ model ; $ this -> attributes = self :: buildRelationshipAttributes ( $ this -> model ) ; $ this -> attributes = $ this -> attributes + self :: buildAttributes ( $ this -> model ) ; return $ this -> attributes ; }
Check the given model and build attribute list .
25,487
private function buildRelationshipAttributes ( $ model ) { $ result = [ ] ; foreach ( $ model -> getSearchRelationships ( ) as $ method ) { if ( ! method_exists ( $ model , $ method ) ) { continue ; } $ relation = self :: getRelation ( $ model -> $ method ( ) ) ; $ this -> relationships [ $ method ] = $ relation ; self :: buildCastedAttributes ( $ relation [ 'model' ] , $ result , $ method ) ; self :: buildSearchAttributes ( $ relation [ 'model' ] , $ result , $ method ) ; } return $ result ; }
Build a list of attributes from the relationships .
25,488
public static function buildAttributes ( $ model ) { $ result = [ ] ; self :: buildCastedAttributes ( $ model , $ result ) ; self :: buildSearchAttributes ( $ model , $ result ) ; return $ result ; }
Build a list of all possible attributes .
25,489
private static function buildCastedAttributes ( $ model , & $ result , $ method = null ) { $ model_name = 'self' ; $ name_append = '' ; if ( ! is_null ( $ method ) ) { $ model_name = $ method ; $ name_append = $ method . '.' ; } if ( class_exists ( 'HnhDigital\ModelSchema\Model' ) && $ model instanceof \ HnhDigital \ ModelSchema \ Model ) { foreach ( $ model -> getSchema ( ) as $ name => $ config ) { $ result [ $ name_append . $ name ] = [ 'name' => $ name , 'title' => Arr :: get ( $ config , 'title' , $ name ) , 'attributes' => [ sprintf ( '%s.%s' , $ model -> getTable ( ) , $ name ) ] , 'filter' => self :: convertCast ( Arr :: get ( $ config , 'cast' ) ) , 'model' => & $ model , 'model_name' => $ model_name , 'source_model' => Arr :: get ( $ config , 'model' ) , 'source_model_key' => Arr :: get ( $ config , 'model_key' , null ) , 'source_model_name' => Arr :: get ( $ config , 'model_name' , 'display_name' ) , ] ; } return ; } foreach ( $ model -> getCasts ( ) as $ name => $ cast ) { $ result [ $ name_append . $ name ] = [ 'name' => $ name , 'title' => $ name , 'attributes' => [ sprintf ( '%s.%s' , $ model -> getTable ( ) , $ name ) ] , 'filter' => self :: convertCast ( $ cast ) , 'model' => & $ model , 'model_name' => $ model_name , ] ; } }
Build attributes based on the casts array on the model .
25,490
private static function validateAttributes ( $ model , $ name , & $ attributes ) { if ( ! is_array ( $ attributes ) ) { $ attributes = [ $ attributes ] ; } if ( empty ( $ attributes ) ) { $ attributes = [ sprintf ( '%s.%s' , $ model -> getTable ( ) , $ name ) ] ; } foreach ( $ attributes as & $ value ) { if ( substr ( $ value , 0 , 1 ) === '#' || substr ( $ value , 0 , 1 ) === '{' ) { $ value = new Expression ( substr ( $ value , 1 ) ) ; } } }
Validate the attributes list .
25,491
private function parseRequest ( $ request ) { if ( empty ( $ request ) ) { return ; } $ this -> request = $ request ; $ models_used = [ ] ; foreach ( $ this -> request as $ name => $ filters ) { if ( ! Arr :: has ( $ this -> attributes , $ name ) ) { continue ; } $ settings = Arr :: get ( $ this -> attributes , $ name ) ; if ( empty ( $ settings ) ) { continue ; } $ filters = self :: validateFilters ( $ filters , $ settings ) ; if ( ( $ model_name = Arr :: get ( $ settings , 'model_name' ) ) === 'self' ) { $ this -> search_models [ 'self' ] [ $ name ] = $ filters ; continue ; } $ models_used [ $ model_name ] = true ; $ this -> search_models [ $ model_name ] [ $ name ] = $ filters ; } if ( count ( $ models_used ) ) { $ this -> modelJoin ( $ models_used ) ; } }
Process the provided request .
25,492
private static function validateFilters ( $ filters , $ settings ) { if ( ! is_array ( $ filters ) ) { $ filters = [ $ filters ] ; } foreach ( $ filters as $ index => & $ filter ) { $ filter = self :: validateFilterItem ( $ filter , $ settings ) ; if ( empty ( $ filter ) ) { unset ( $ filters [ $ index ] ) ; } } return $ filters ; }
Validate the given filter .
25,493
private static function validateFilterItem ( $ filter , $ settings ) { if ( ! is_array ( $ filter ) ) { $ filter = [ '' , $ filter ] ; } if ( Arr :: get ( $ settings , 'filter' ) !== 'boolean' && count ( $ filter ) == 1 ) { array_unshift ( $ filter , '' ) ; } $ operator = Arr :: get ( $ filter , 0 , '' ) ; $ value_one = Arr :: get ( $ filter , 1 , false ) ; $ value_two = Arr :: get ( $ filter , 2 , false ) ; if ( Arr :: has ( $ settings , 'enable.wild-all' ) ) { self :: applyWildAll ( $ operator , $ value_one ) ; } self :: checkInlineOperator ( $ operator , $ value_one , $ settings ) ; self :: checkNullOperator ( $ operator , $ value_one ) ; self :: checkEmptyOperator ( $ operator , $ value_one ) ; if ( empty ( $ operator ) ) { $ operator = self :: getDefaultOperator ( Arr :: get ( $ settings , 'filter' ) , $ operator ) ; } $ filter = [ 'operator' => $ operator , 'method' => 'where' , 'arguments' => [ ] , 'value_one' => $ value_one , 'value_two' => $ value_two , 'settings' => $ settings , 'positive' => true , ] ; $ validation_method = 'filterBy' . Str :: studly ( Arr :: get ( $ settings , 'filter' ) ) ; if ( method_exists ( __CLASS__ , $ validation_method ) ) { $ filter = self :: { $ validation_method } ( $ filter ) ; } if ( $ filter === false ) { return $ filter ; } $ filter [ 'positive' ] = ! ( stripos ( $ operator , '!' ) !== false || stripos ( $ operator , 'NOT' ) !== false ) ; return $ filter ; }
Validate each entry .
25,494
private static function applyWildAll ( & $ operator , & $ value ) { $ positive = ! ( stripos ( $ operator , '!' ) !== false || stripos ( $ operator , 'NOT' ) !== false ) ; $ operator = $ positive ? '*=*' : '*!=*' ; $ value_array = str_split ( str_replace ( ' ' , '' , $ value ) ) ; $ value = implode ( '%' , $ value_array ) ; }
Applies a wildcard for between every character .
25,495
public static function parseInlineOperator ( $ text ) { $ operator_name = 'contains' ; $ operator = Arr :: get ( $ text , 0 , '' ) ; $ value = Arr :: get ( $ text , 1 , false ) ; self :: checkInlineOperator ( $ operator , $ value ) ; if ( ! empty ( $ operator ) ) { $ operator_name = Arr :: get ( self :: getOperator ( 'string' , $ operator ) , 'inline' , 'contains' ) ; } return [ $ operator_name , $ operator , $ value , ] ; }
Parse any inline operator .
25,496
private static function checkInlineOperator ( & $ operator , & $ value , $ settings = [ ] ) { if ( is_array ( $ value ) ) { return ; } if ( Arr :: get ( $ settings , 'filter' ) === 'boolean' ) { return ; } $ value_array = explode ( ' ' , trim ( $ value ) , 2 ) ; if ( count ( $ value_array ) == 1 ) { return ; } $ check_operator = array_shift ( $ value_array ) ; if ( self :: checkOperator ( Arr :: get ( $ settings , 'filter' , 'string' ) , $ check_operator ) ) { $ operator = $ check_operator ; $ value = array_shift ( $ value_array ) ; } }
Check the value for inline operator .
25,497
public static function filterByUuid ( $ filter ) { $ operator = Arr :: get ( $ filter , 'operator' ) ; $ method = Arr :: get ( $ filter , 'method' ) ; $ arguments = Arr :: get ( $ filter , 'arguments' ) ; $ value_one = Arr :: get ( $ filter , 'value_one' ) ; $ value_two = Arr :: get ( $ filter , 'value_two' ) ; $ settings = Arr :: get ( $ filter , 'settings' ) ; $ positive = Arr :: get ( $ filter , 'positive' ) ; switch ( $ operator ) { case 'IN' : $ method = 'whereIn' ; $ arguments = [ static :: getListFromString ( $ value_one ) ] ; break ; case 'NOT_IN' : $ method = 'whereNotIn' ; $ arguments = [ static :: getListFromString ( $ value_one ) ] ; break ; case 'NULL' : $ method = 'whereNull' ; break ; case 'NOT_NULL' : $ method = 'whereNotNull' ; break ; } return [ 'operator' => $ operator , 'method' => $ method , 'arguments' => $ arguments , 'value_one' => $ value_one , 'value_two' => $ value_two , 'settings' => $ settings , 'positive' => $ positive , ] ; }
Filter by UUID .
25,498
public static function filterByString ( $ filter ) { $ operator = Arr :: get ( $ filter , 'operator' ) ; $ method = Arr :: get ( $ filter , 'method' ) ; $ arguments = Arr :: get ( $ filter , 'arguments' ) ; $ value_one = Arr :: get ( $ filter , 'value_one' ) ; $ value_two = Arr :: get ( $ filter , 'value_two' ) ; $ settings = Arr :: get ( $ filter , 'settings' ) ; $ positive = Arr :: get ( $ filter , 'positive' ) ; switch ( $ operator ) { case '=' : case '!=' : $ arguments = [ $ operator , $ value_one ] ; break ; case '*=*' : case '*!=*' : $ operator = ( stripos ( $ operator , '!' ) !== false ) ? 'not ' : '' ; $ operator .= 'like' ; $ arguments = [ $ operator , '%' . $ value_one . '%' ] ; break ; case '*=' : case '*!=' : $ operator = ( stripos ( $ operator , '!' ) !== false ) ? 'not ' : '' ; $ operator .= 'like' ; $ arguments = [ $ operator , '%' . $ value_one ] ; break ; case '=*' : case '!=*' : $ operator = ( stripos ( $ operator , '!' ) !== false ) ? 'not ' : '' ; $ operator .= 'like' ; $ arguments = [ $ operator , $ value_one . '%' ] ; break ; case 'EMPTY' : $ method = 'whereRaw' ; $ arguments = "%s = ''" ; break ; case 'NOT_EMPTY' : $ method = 'whereRaw' ; $ arguments = "%s != ''" ; break ; case 'IN' : $ method = 'whereIn' ; $ arguments = [ static :: getListFromString ( $ value_one ) ] ; break ; case 'NOT_IN' : $ method = 'whereNotIn' ; $ arguments = [ static :: getListFromString ( $ value_one ) ] ; break ; case 'NULL' : $ method = 'whereNull' ; break ; case 'NOT_NULL' : $ method = 'whereNotNull' ; break ; } return [ 'operator' => $ operator , 'method' => $ method , 'arguments' => $ arguments , 'value_one' => $ value_one , 'value_two' => $ value_two , 'settings' => $ settings , 'positive' => $ positive , ] ; }
Filter by string .
25,499
public static function filterByScope ( $ filter ) { $ operator = Arr :: get ( $ filter , 'operator' ) ; $ method = Arr :: get ( $ filter , 'method' ) ; $ source = Arr :: get ( $ filter , 'settings.source' ) ; $ arguments = Arr :: get ( $ filter , 'arguments' ) ; $ value_one = Arr :: get ( $ filter , 'value_one' ) ; $ value_two = Arr :: get ( $ filter , 'value_two' ) ; $ settings = Arr :: get ( $ filter , 'settings' ) ; $ positive = Arr :: get ( $ filter , 'positive' ) ; if ( Arr :: has ( $ filter , 'settings.source' ) ) { $ model = Arr :: get ( $ filter , 'settings.model' ) ; $ method_transform = 'transform' . Str :: studly ( $ source ) . 'Value' ; if ( method_exists ( $ model , $ method_transform ) ) { $ value_one = $ model -> $ method_transform ( $ value_one ) ; } $ method_lookup = 'scope' . Str :: studly ( $ source ) ; if ( ! method_exists ( $ model , $ method_lookup ) ) { return false ; } $ method = Str :: camel ( $ source ) ; $ arguments = [ $ value_one ] ; } return [ 'operator' => $ operator , 'method' => $ method , 'arguments' => $ arguments , 'value_one' => $ value_one , 'value_two' => $ value_two , 'settings' => $ settings , 'positive' => $ positive , ] ; }
Filter by scope .