idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
230,800
protected function renderTemplate ( $ path = false ) { if ( ! $ this -> templateEngine ) { throw new \ Exception ( 'template engine not injected' ) ; } if ( ! $ path ) { $ path = sprintf ( '%s/%s/%s' , AREA , $ this -> name , $ this -> action ) ; } $ this -> setCommonTemplateParameters ( ) ; $ html = $ this -> template...
Renders template and writes output to HTTP stream
230,801
public function _async_attachment_images ( $ atts , $ attachment , $ size ) { if ( ! $ this -> _is_async_attachment_images ( ) ) { return $ atts ; } $ atts [ 'data-src' ] = $ atts [ 'src' ] ; $ atts [ 'src' ] = wp_get_attachment_image_url ( $ attachment -> ID , 'wppso-minimum-thumbnail' ) ; if ( isset ( $ atts [ 'srcse...
Aync loading of attachment images
230,802
public function _async_content_images ( $ content ) { if ( ! $ this -> _is_async_content_images ( ) ) { return $ content ; } if ( ! preg_match_all ( '/<img [^>]+>/' , $ content , $ matches ) ) { return $ content ; } $ selected_images = [ ] ; foreach ( $ matches [ 0 ] as $ image ) { if ( false === strpos ( $ image , ' d...
Aync loading of content images
230,803
protected function _add_data_src_to_content_image ( $ image , $ image_id ) { return preg_replace_callback ( '@(<img decoding="async"[^>]*?) src="([^"]+?)"([^>]*?>)@m' , function ( $ matches ) use ( $ image_id ) { return sprintf ( '%s src="%s" data-src="%s" %s' , $ matches [ 1 ] , wp_get_attachment_image_url ( $ image_i...
Add data - src to content image
230,804
protected function _add_data_srcset_to_content_image ( $ image , $ image_id ) { return preg_replace_callback ( '@(<img decoding="async"[^>]*?)srcset="([^"]+?)"([^>]*?>)@m' , function ( $ matches ) use ( $ image_id ) { return sprintf ( '%s srcset="" data-srcset="%s" %s' , $ matches [ 1 ] , $ matches [ 2 ] , $ matches [ ...
Add data - srcset to content image
230,805
public function createFormForModel ( string $ classname , DAO $ dao ) { if ( ! is_a ( $ classname , Model :: class , true ) ) throw new \ InvalidArgumentException ( "Not a valid Model class provided" ) ; $ form = new Form ( $ classname ) ; $ refl = new ReflectionClass ( $ classname ) ; $ fields = $ this -> getAnnotated...
Create a form based on a database model
230,806
public function createFormForObject ( string $ formclass ) { if ( ! is_a ( $ formclass , BaseForm :: class , true ) ) throw new \ InvalidArgumentException ( "Not a valid BaseForm class provided" ) ; $ form = new Form ( $ formclass ) ; $ refl = new \ ReflectionClass ( $ formclass ) ; $ field_validators = $ formclass :: ...
Create a form using reflection on a POPO .
230,807
protected function addFormValidators ( ReflectionClass $ refl , array $ additional_validators , Form $ form ) { $ classdoc = $ refl -> getDocComment ( ) ; if ( ! empty ( $ classdoc ) ) { $ classdoc = new DocComment ( $ classdoc ) ; foreach ( $ classdoc -> getAnnotations ( 'validator' ) as $ validator ) { if ( ! is_a ( ...
Add validators for the whole form
230,808
protected function getAnnotatedFields ( ReflectionClass $ class , array $ field_validators ) { $ properties = $ class -> getProperties ( ReflectionProperty :: IS_PUBLIC ) ; $ fields = [ ] ; foreach ( $ properties as $ prop ) { $ name = $ prop -> getName ( ) ; $ comment = $ prop -> getDocComment ( ) ; if ( $ comment ===...
Iterate over all properties and add their values to the form
230,809
protected function bindValue ( FormElement $ element , ReflectionClass $ refl , $ instance ) { $ name = $ element -> getName ( true ) ; if ( substr ( $ name , 0 , 1 ) === "_" ) return ; $ value = $ element -> getValue ( ) ; $ method_name = "set" . strtoupper ( substr ( $ name , 0 , 1 ) ) . substr ( $ name , 1 ) ; if ( ...
Set a value from a form to an instance of a class
230,810
private function buildUrl ( $ path ) { $ key = $ this -> patrol -> getApiKey ( ) ; $ secret = $ this -> patrol -> getApiSecret ( ) ; $ base = $ this -> patrol -> apiBase ; $ url = $ base . '/' . $ path . '?key=' . $ key . '&secret=' . $ secret ; if ( $ this -> method === "get" && ! is_null ( $ this -> payload ) ) { $ q...
Takes a path and builds the URL with the given key and secret
230,811
public static function compare ( $ known , $ user ) { if ( strlen ( $ known ) !== strlen ( $ user ) ) { return false ; } $ result = 0 ; $ knownLength = strlen ( $ known ) ; for ( $ i = 0 ; $ i < $ knownLength ; $ i ++ ) { $ result |= ord ( $ known [ $ i ] ) ^ ord ( $ user [ $ i ] ) ; } return $ result == 0 ; }
Compares two strings securely .
230,812
public function _run ( ) { if ( defined ( "NOT_FOUND" ) ) { ( new Controller ( ) ) -> load -> error ( 404 ) ; } if ( Configer :: manualRoute ( ) ) { $ router = Router :: getInstance ( $ this -> segments ) ; Configer :: loadRoutes ( ) ; try { if ( $ action = $ router -> run ( ) ) { if ( is_array ( $ action ) ) { $ class...
Here we go ...
230,813
protected function setIfDefined ( $ object , $ field ) { $ propertyAccessor = $ this -> getPropertyAccessor ( ) ; if ( ! $ this -> _has ( $ field ) ) { return $ propertyAccessor -> isReadable ( $ object , $ field ) ? $ propertyAccessor -> getValue ( $ object , $ field ) : null ; } $ propertyAccessor -> setValue ( $ obj...
Define given field on given object if accessible
230,814
public function addLocalVariable ( $ localVariable ) { $ varName = $ localVariable ; if ( strpos ( $ varName , '$' ) === 0 ) { $ varName = substr ( $ localVariable , 1 ) ; } if ( in_array ( $ varName , $ this -> localVariables ) === false ) { $ this -> localVariables [ ] = $ varName ; } }
Add a local variable so that any usage of it doesn t trigger trying to fetch it from the ViewModel
230,815
public static function getNamespace ( $ namespaceClass ) { if ( is_object ( $ namespaceClass ) === true ) { $ namespaceClass = get_class ( $ namespaceClass ) ; } $ lastSlashPosition = mb_strrpos ( $ namespaceClass , '\\' ) ; if ( $ lastSlashPosition !== false ) { return mb_substr ( $ namespaceClass , 0 , $ lastSlashPos...
Get the name space part of a fully namespaced class . Returns empty string if the class had no namespace part .
230,816
public static function getClassName ( $ namespaceClass ) { $ lastSlashPosition = mb_strrpos ( $ namespaceClass , '\\' ) ; if ( $ lastSlashPosition !== false ) { return mb_substr ( $ namespaceClass , $ lastSlashPosition + 1 ) ; } return $ namespaceClass ; }
Get the class part of a fully namespaced class name
230,817
public function ensureDirectoryExists ( $ outputFilename ) { $ directoryName = dirname ( $ outputFilename ) ; @ mkdir ( $ directoryName , 0755 , true ) ; if ( file_exists ( $ directoryName ) === false ) { throw new JigException ( "Directory $directoryName does not exist and could not be created" ) ; } }
ensureDirectoryExists by creating it with 0755 permissions and throwing an exception if it does not exst after that mkdir call .
230,818
public function create ( ) { $ slug = $ this -> getParameter ( 'value' ) ; $ allowSlashes = StringUtils :: strToBool ( $ this -> getParameter ( 'allowSlashes' ) ) ; return SlugUtils :: createSlug ( $ slug , $ allowSlashes ) ; }
Returns a slug for the specified parameter
230,819
public function mailer ( ) { if ( is_null ( $ this -> mailerInstance ) ) { $ mailer = new Mailer ( ViewFactory :: i ( ) , $ this -> swiftMailer ( ) ) ; if ( $ queue = UniversalBuilder :: resolve ( 'queue.connection' ) ) $ mailer -> setQueue ( $ queue ) ; $ from = Config :: get ( 'mail.from' ) ; if ( is_array ( $ from )...
mailer . mailer
230,820
public function withDataCell ( string $ tableDataCellClassName ) : TableColumnFieldDefiner { if ( ! is_subclass_of ( $ tableDataCellClassName , TableDataCell :: class , true ) ) { throw InvalidArgumentException :: format ( 'Invalid class supplied to %s: expecting subclass of %s, %s given' , __METHOD__ , TableDataCell :...
Defines the cell class for the table .
230,821
public function put ( $ key , $ value , $ duration , $ localOnly = false ) { return parent :: put ( $ key , $ value , $ this -> cacheExpiration ) ; }
Writes the cache value to all of our cache stores
230,822
public static function boot ( ) { parent :: boot ( ) ; self :: saving ( function ( $ model ) { return $ model -> beforeSave ( ) ; } ) ; self :: saved ( function ( $ model ) { return $ model -> afterSave ( ) ; } ) ; self :: deleting ( function ( $ model ) { return $ model -> beforeDelete ( ) ; } ) ; self :: deleted ( fu...
Setup the model events
230,823
public function save ( array $ options = array ( ) , $ force = false ) { if ( $ force || $ this -> validate ( ) ) { return $ this -> performSave ( $ options ) ; } else { return false ; } }
Persist the model to the DB if it s valid
230,824
protected function performSave ( array $ options ) { $ this -> purgeAttributes ( ) ; $ this -> saved = true ; return parent :: save ( $ options ) ; }
Save the model on the database
230,825
protected function validate ( ) { $ rules = $ this -> mergeRules ( ) ; if ( empty ( $ rules ) ) return true ; $ data = $ this -> attributes ; $ validator = Validator :: make ( $ data , $ rules ) ; $ success = $ validator -> passes ( ) ; if ( $ success ) { if ( $ this -> validationErrors -> count ( ) > 0 ) { $ this -> v...
Validate the model by the defined rules
230,826
private function mergeRules ( ) { $ rules = static :: $ rules ; $ output = array ( ) ; if ( empty ( $ rules ) ) { return $ output ; } if ( $ this -> exists ) { $ merged = ( isset ( $ rules [ 'update' ] ) ) ? array_merge_recursive ( $ rules [ 'save' ] , $ rules [ 'update' ] ) : $ rules [ 'save' ] ; } else { $ merged = (...
Return a single array with the rules for the action required
230,827
protected function purgeAttributes ( ) { $ attributes = $ this -> getPurgeAttributes ( ) ; if ( ! empty ( $ attributes ) ) { foreach ( $ attributes as $ attribute ) { unset ( $ this -> attributes [ $ attribute ] ) ; } } }
Purge the attributes that are not a field on the database table to prevent error during the save
230,828
public function getList ( array $ data = array ( ) ) { $ sql = 'SELECT b.*, u.name AS user_name' ; if ( ! empty ( $ data [ 'count' ] ) ) { $ sql = 'SELECT COUNT(b.backup_id)' ; } $ sql .= ' FROM backup b LEFT JOIN user u ON(b.user_id = u.user_id) WHERE b.backup_id > 0' ; $ where = arra...
Returns an array of backups or counts them
230,829
public function add ( array $ data ) { $ result = null ; $ this -> hook -> attach ( 'module.backup.add.before' , $ data , $ result , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ version = null ; if ( isset ( $ data [ 'version' ] ) ) { $ version = $ data [ 'version' ] ; } if ( $ this -> exists ( $ data [...
Adds a backup to the database
230,830
public function delete ( $ id ) { $ result = null ; $ this -> hook -> attach ( 'module.backup.delete.before' , $ id , $ this ) ; if ( isset ( $ result ) ) { return $ result ; } $ result = $ this -> deleteZip ( $ id ) ; if ( $ result ) { $ this -> db -> delete ( 'backup' , array ( 'backup_id' => $ id ) ) ; } $ this -> h...
Deletes a backup from disk and database
230,831
protected function deleteZip ( $ backup_id ) { $ backup = $ this -> get ( $ backup_id ) ; if ( empty ( $ backup [ 'path' ] ) ) { return false ; } $ file = gplcart_file_absolute ( $ backup [ 'path' ] ) ; return file_exists ( $ file ) && unlink ( $ file ) ; }
Deletes a backup ZIP archive
230,832
public function exists ( $ id , $ version = null ) { $ list = $ this -> getList ( array ( 'id' => $ id , 'version' => $ version ) ) ; return ! empty ( $ list ) ; }
Whether a backup already exists
230,833
protected function callHandler ( $ handler_id , $ method , array $ arguments ) { try { $ handlers = $ this -> getHandlers ( ) ; return Handler :: call ( $ handlers , $ handler_id , $ method , $ arguments ) ; } catch ( Exception $ ex ) { return $ ex -> getMessage ( ) ; } }
Cal a handler
230,834
public function diff ( Snapshot $ other ) { return new self ( $ this -> _time - $ other -> getTime ( ) , $ this -> _memoryUsage - $ other -> getMemoryUsage ( ) , $ this -> _realMemoryUsage - $ other -> getRealMemoryUsage ( ) , ( $ this -> _memoryUsagePeak + $ other -> getMemoryUsagePeak ( ) ) / 2 , ( $ this -> _realMem...
Subtracts a snapshot from another one .
230,835
public static function create ( ) { return new self ( microtime ( true ) , memory_get_usage ( false ) , memory_get_usage ( true ) , memory_get_peak_usage ( false ) , memory_get_peak_usage ( true ) ) ; }
Creates a new snapshot based on current PHP environment metrics
230,836
function ReportSiteAction ( Site $ site , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Site ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logSite = new LogSite ( ) ; $ logSite -> SetLogItem ( $ logItem ) ; $ logSite -> SetSite ( $ site ) ;...
Reports a site action to the log
230,837
function ReportPageAction ( Page $ page , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Page ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logPage = new LogPage ( ) ; $ logPage -> SetLogItem ( $ logItem ) ; $ logPage -> SetPage ( $ page ) ;...
Reports a page action with dependencies to the log
230,838
function ReportAreaAction ( Area $ area , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Area ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logArea = new LogArea ( ) ; $ logArea -> SetLogItem ( $ logItem ) ; $ logArea -> SetArea ( $ area ) ;...
Reports an area action with dependencies to the log
230,839
function ReportLayoutAction ( Layout $ layout , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Layout ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logLayout = new LogLayout ( ) ; $ logLayout -> SetLogItem ( $ logItem ) ; $ logLayout -> SetL...
Reports a layout action with dependencies to the log
230,840
function ReportContainerAction ( Container $ container , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Container ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logContainer = new LogContainer ( ) ; $ logContainer -> SetContainer ( $ containe...
Reports a container action with dependencies to the log
230,841
function ReportContentAction ( Content $ content , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Content ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logContent = new LogContent ( ) ; $ logContent -> SetLogItem ( $ logItem ) ; $ logContent...
Reports a content action with dependencies to the log
230,842
function ReportMemberAction ( Member $ member , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Member ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logMember = new LogMember ( ) ; $ logMember -> SetLogItem ( $ logItem ) ; $ logMember -> SetM...
Reports a member action to the log
230,843
function ReportMemberGroupAction ( Membergroup $ memberGroup , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: MemberGroup ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logMemberGroup = new LogMembergroup ( ) ; $ logMemberGroup -> SetLogItem ...
Reports a member group action to the log
230,844
function ReportUserAction ( User $ user , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: User ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logUser = new LogUser ( ) ; $ logUser -> SetLogItem ( $ logItem ) ; $ logUser -> SetUser ( $ user ) ;...
Reports a user action to the log
230,845
function ReportUserGroupAction ( Usergroup $ userGroup , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: UserGroup ( ) , $ action ) ; if ( ! $ action -> Equals ( Enums \ Action :: Delete ( ) ) ) { $ logUserGroup = new LogUsergroup ( ) ; $ logUserGroup -> SetLogItem ( $ logItem ) ...
Reports a user group action to the log
230,846
function ReportTemplateAction ( $ moduleType , $ template , Enums \ Action $ action ) { $ logItem = $ this -> CreateLogItem ( Enums \ ObjectType :: Template ( ) , $ action ) ; $ logTemplate = new LogTemplate ; $ logTemplate -> SetLogItem ( $ logItem ) ; $ logTemplate -> SetModuleType ( $ moduleType ) ; $ logTemplate ->...
Reports an action on a module template
230,847
private function CreateLogItem ( Enums \ ObjectType $ objType , Enums \ Action $ action ) { $ this -> DeleteOldLogItems ( ) ; $ item = new LogItem ( ) ; $ item -> SetChanged ( Date :: Now ( ) ) ; $ item -> SetAction ( ( string ) $ action ) ; $ item -> SetObjectType ( ( string ) $ objType ) ; $ item -> SetUser ( $ this ...
Creates a log item
230,848
private function DeleteOldLogItems ( ) { $ days = SettingsProxy :: Singleton ( ) -> Settings ( ) -> GetLogLifetime ( ) ; $ deleteBefore = Date :: Now ( ) ; $ deleteBefore -> AddDays ( - $ days ) ; $ tblLogItem = LogItem :: Schema ( ) -> Table ( ) ; $ sql = Access :: SqlBuilder ( ) ; $ where = $ sql -> LT ( $ tblLogItem...
Deletes log items older then the given amount of days
230,849
public static function classNameShort ( $ class ) { $ className = self :: className ( $ class ) ; $ position = strrpos ( $ className , '\\' ) ; $ name = substr ( $ className , $ position + 1 ) ; return $ name ; }
Returns only the class name
230,850
public static function classHasMethod ( $ method , $ class ) { $ methods = self :: classMethods ( $ class ) ; if ( ! in_array ( $ method , $ methods ) ) { return false ; } return true ; }
Check if class has method
230,851
public static function hash ( $ data , $ file = false ) { $ hasher = new \ Nuki \ Handlers \ Security \ Hasher ( self :: getAppAlgorithm ( ) , self :: getAppKey ( ) ) ; return $ hasher -> hash ( $ data , $ file ) ; }
Hash by data or filename
230,852
public static function encrypt ( $ data ) : Encrypted { $ crypter = new Crypter ( ) ; return $ crypter -> encrypt ( $ data , self :: getAppKey ( ) ) ; }
Encrypt data and return an encrypter object
230,853
public static function decrypt ( $ data ) : string { $ crypter = new Crypter ( ) ; return $ crypter -> decrypt ( $ data , self :: getAppKey ( ) ) ; }
Decrypt data and return the decrypted value
230,854
public static function loadCoreView ( string $ name ) { $ base = __DIR__ . '/../../Views/' ; if ( ! file_exists ( $ base . $ name . '.view' ) ) { throw new \ Nuki \ Exceptions \ Base ( 'The view file "' . $ name . '" does not exist.' ) ; } return file_get_contents ( $ base . $ name . '.view' ) ; }
Load the contents of a core view file
230,855
public static function makeFromInteger ( $ integer ) { if ( $ integer == 0 ) return static :: $ chars [ 0 ] ; $ number = abs ( $ integer ) ; if ( $ integer < 0 ) throw new \ InvalidArgumentException ( "Can not encode for negative integers" ) ; $ string = '' ; $ base = strlen ( static :: $ chars ) ; while ( $ number > 0...
Make a unique string from an Integer
230,856
public static function decodeToInteger ( $ string ) { $ stringLength = strlen ( $ string ) ; $ baseLength = strlen ( static :: $ chars ) ; $ id = 0 ; for ( $ i = 0 ; $ i < $ stringLength ; $ i ++ ) { $ pos = strpos ( static :: $ chars , $ string [ $ i ] ) ; $ id = ( $ id * $ baseLength ) + $ pos ; } return $ id ; }
Decode the encoded string to Integer
230,857
public function getMenu ( DTO $ dto = null ) { if ( ! $ menu = $ this -> SystemCache -> get ( 'cms-menu' ) ) { $ menu = array ( ) ; if ( $ dto === null ) $ dto = new DTO ( ) ; $ dto -> setOrderBy ( 'SortOrder' , 'ASC' ) ; $ dto -> setParameter ( 'FlattenChildren' , false ) ; $ dto -> setParameter ( 'Enabled' , true ) ;...
Returns an array that represents the CMS Navigation menu
230,858
public function asError ( $ status = self :: INTERNAL_ERROR ) { if ( $ this -> error_views ) { $ stream = $ this -> error_views -> getStream ( $ status ) ; } else { $ stream = null ; } return Response :: error ( $ status , $ this -> data , $ stream ) ; }
return a response with error number .
230,859
protected function switchContentType ( $ data ) { switch ( $ this -> format ) { case 'application/json' : $ data = json_encode ( is_object ( $ data ) ? ( array ) $ data : $ data ) ; break ; case 'application/xml' : $ data = is_object ( $ data ) ? ( string ) $ data : $ data ; break ; default : $ data = ( string ) $ data...
Switch content type
230,860
public function extraValidation ( $ data , $ performPhoneValidation = true ) { $ this -> messages = new MessageBag ; if ( ( ! $ this -> userRepository -> validatePhoneNumber ( $ data [ 'phone_number' ] ) ) && ( $ performPhoneValidation ) ) { $ this -> messages -> add ( 'phone_number' , 'There is a problem with your pho...
Perform extra validation
230,861
public function toSQL ( Parameters $ params , bool $ inner_clause ) { if ( $ inner_clause ) return '(' . $ this -> getSQL ( ) . ')' ; return $ this -> getSQL ( ) ; }
Add a custom SQL string to the query
230,862
public static function redis ( ) { $ pid = getmypid ( ) ; if ( self :: $ pid !== $ pid ) { self :: $ redis = null ; self :: $ pid = $ pid ; } if ( ! is_null ( self :: $ redis ) ) { return self :: $ redis ; } $ server = self :: $ redisServer ; if ( empty ( $ server ) ) { $ server = 'localhost:6379' ; } if ( is_array ( $...
Return an instance of the Redis class instantiated for Resque .
230,863
public static function runAll ( $ value ) { foreach ( get_class_methods ( __CLASS__ ) as $ method ) { if ( strpos ( $ method , 'run' ) === 0 ) { continue ; } $ value = self :: $ method ( $ value ) ; } return $ value ; }
Runs all converter functions
230,864
public function addInsert ( array $ rows ) : self { if ( ! empty ( $ rows ) && ! is_array ( reset ( $ rows ) ) ) { $ rows = [ $ rows ] ; } foreach ( $ rows as $ index => $ row ) { if ( ! is_array ( $ row ) ) { return $ this -> handleException ( InvalidArgumentException :: create ( 'Argument $rows[' . $ index . ']' , $ ...
Adds a row to insert to the table .
230,865
public function addInsertFromSelect ( $ columns , $ selectQuery = null ) : self { if ( $ selectQuery === null ) { $ selectQuery = $ columns ; $ columns = null ; } if ( $ columns !== null ) { if ( ! is_array ( $ columns ) ) { return $ this -> handleException ( InvalidArgumentException :: create ( 'Argument $columns' , $...
Adds an instruction that the query should insert values to the table from the select query .
230,866
final public function validate ( ) : bool { if ( $ this -> _tokenRequired && ! $ this -> _tokenOk ) { App :: $ Session -> getFlashBag ( ) -> add ( 'warning' , __ ( 'Hack attention: security token is wrong!' ) ) ; return false ; } $ rules = $ this -> rules ( ) ; $ defaultAttr = $ this -> getAllProperties ( ) ; $ success...
Validate defined rules in app
230,867
public function getAllProperties ( ) : ? array { $ properties = null ; foreach ( $ this as $ property => $ value ) { if ( Str :: startsWith ( '_' , $ property ) ) { continue ; } $ properties [ $ property ] = $ value ; } return $ properties ; }
Get all properties for current model in key = > value array
230,868
public function clearProperties ( ) : void { foreach ( $ this as $ property => $ value ) { if ( ! Str :: startsWith ( '_' , $ property ) ) { $ this -> { $ property } = null ; } } }
Cleanup all public model properties
230,869
final public function getValidationRule ( $ field ) : array { $ rules = $ this -> rules ( ) ; $ response = [ ] ; foreach ( $ rules as $ rule ) { if ( Any :: isArray ( $ rule [ 0 ] ) ) { foreach ( $ rule [ 0 ] as $ tfield ) { if ( $ tfield == $ field ) { $ response [ $ rule [ 1 ] ] = $ rule [ 2 ] ; } } } else { if ( $ r...
Get validation rules for field
230,870
public function attach ( $ serviceClassName , array $ options = [ ] ) { if ( true === isset ( $ this -> service [ $ serviceClassName ] ) ) { throw new DuplicateEntryException ( 'The service "' . $ serviceClassName . '" was already attached to the service factory.' , 1456418859 ) ; } $ this -> currentService = $ service...
Will attach a service to this factory .
230,871
public function get ( $ serviceClassName ) { if ( false === $ this -> hasBeenInitialized ) { throw new InitializationNotSetException ( 'You can get a service instance only when the service factory has been initialized.' , 1456419587 ) ; } if ( false === $ this -> has ( $ serviceClassName ) ) { throw new EntryNotFoundEx...
Returns the wanted service if it was previously registered .
230,872
public function with ( $ serviceClassName ) { if ( false === $ this -> has ( $ serviceClassName ) ) { throw new Exception ( 'You cannot use the function "' . __FUNCTION__ . '" on a service which was not added to the factory (service used: "' . $ serviceClassName . '").' , 1459425398 ) ; } $ this -> currentService = $ s...
Resets the current service value to the given service allowing the usage of the function setOption with this service .
230,873
public function getOption ( $ optionName ) { return ( isset ( $ this -> service [ $ this -> currentService ] [ 'options' ] [ $ optionName ] ) ) ? $ this -> service [ $ this -> currentService ] [ 'options' ] [ $ optionName ] : null ; }
Returns an option for the current service . If the option is not found null is returned .
230,874
public function initialize ( ) { if ( true === $ this -> hasBeenInitialized ) { return ; } $ this -> hasBeenInitialized = true ; foreach ( $ this -> service as $ service ) { list ( $ serviceClassName , $ serviceOptions ) = $ this -> manageServiceData ( $ service ) ; $ this -> serviceInstances [ $ serviceClassName ] = $...
Initializes every single service which was added in this instance .
230,875
public function runServicesFromEvent ( $ serviceEvent , $ eventMethodName , AbstractServiceDTO $ dto ) { if ( false === $ this -> hasBeenInitialized ) { return ; } $ this -> checkServiceEvent ( $ serviceEvent ) ; $ this -> checkServiceEventMethodName ( $ serviceEvent , $ eventMethodName ) ; $ serviceInstances = $ this ...
Will loop on each registered service in this factory and check if they use the requested event . If they do the event is dispatched .
230,876
protected function checkServiceEvent ( $ serviceEvent ) { if ( false === isset ( self :: $ servicesChecked [ $ serviceEvent ] ) ) { self :: $ servicesChecked [ $ serviceEvent ] = [ ] ; if ( false === in_array ( ServiceEventInterface :: class , class_implements ( $ serviceEvent ) ) ) { throw new WrongInheritanceExceptio...
Will check if the class of the service event is correct and implements the correct interface .
230,877
protected function checkServiceEventMethodName ( $ serviceEvent , $ eventMethodName ) { if ( false === in_array ( $ eventMethodName , self :: $ servicesChecked [ $ serviceEvent ] ) ) { $ eventClassReflection = ReflectionService :: get ( ) -> getClassReflection ( $ serviceEvent ) ; self :: $ servicesChecked [ $ serviceE...
Will check if the given method exists in the service event .
230,878
protected function getServicesFromEvent ( $ serviceEvent ) { if ( false === isset ( $ this -> servicesEvents [ $ serviceEvent ] ) ) { $ servicesInstances = [ ] ; foreach ( $ this -> serviceInstances as $ serviceInstance ) { if ( $ serviceInstance instanceof $ serviceEvent ) { $ servicesInstances [ ] = $ serviceInstance...
Will loop trough all the services instance and get the ones which use the given event .
230,879
private function migrate ( $ outputLog ) { try { DB :: connection ( ) -> getPdo ( ) ; DB :: unprepared ( file_get_contents ( 'core/database.sql' ) ) ; } catch ( Exception $ e ) { return $ this -> response ( $ e -> getMessage ( ) ) ; } return $ this -> seed ( $ outputLog ) ; }
Run the migration and call the seeder .
230,880
private function sqlite ( $ outputLog ) { if ( DB :: connection ( ) instanceof SQLiteConnection ) { $ database = DB :: connection ( ) -> getDatabaseName ( ) ; if ( ! file_exists ( $ database ) ) { touch ( $ database ) ; DB :: reconnect ( Config :: get ( 'database.default' ) ) ; } $ outputLog -> write ( 'Using SqlLite d...
check database type . If SQLite then create the database file .
230,881
public function build ( StorageFacilityInfo $ sfInfo ) { $ storageFacility = $ this -> ApplicationContext -> object ( $ sfInfo -> ObjectRef ) ; return $ storageFacility ; }
Get a storage facility prototype instance from the application context
230,882
public static function compareFiles ( $ file1 , $ file2 , $ compareCharacters = false ) { return self :: compare ( file_get_contents ( $ file1 ) , file_get_contents ( $ file2 ) , $ compareCharacters ) ; }
Returns the diff for two files .
230,883
public static function toString ( $ diff , $ separator = "\n" ) { $ string = '' ; foreach ( $ diff as $ line ) { switch ( $ line [ 1 ] ) { case self :: UNMODIFIED : $ string .= ' ' . $ line [ 0 ] ; break ; case self :: DELETED : $ string .= '- ' . $ line [ 0 ] ; break ; case self :: INSERTED : $ string .= '+ ' . $ lin...
Returns a diff as a string where unmodified lines are prefixed by deletions are prefixed by - and insertions are prefixed by + .
230,884
public static function toTable ( $ diff , $ indentation = '' , $ separator = '<br />' ) { $ html = $ indentation . "<table class=\"diff\">\n" ; $ index = 0 ; while ( $ index < count ( $ diff ) ) { switch ( $ diff [ $ index ] [ 1 ] ) { case self :: UNMODIFIED : $ leftCell = self :: getCellContent ( $ diff , $ indentatio...
Returns a diff as an HTML table .
230,885
public function checkChars ( $ value ) { if ( strlen ( $ value ) != 8 ) { if ( strpos ( $ value , 'X' ) !== false ) { return false ; } } return parent :: checkChars ( $ value ) ; }
Allows X on length of 8 chars
230,886
public function submitSubscribe ( $ listID , $ composedItem = [ ] ) { $ results = $ this -> mailChimp -> call ( "lists/subscribe" , [ 'id' => $ listID , 'email' => [ 'email' => $ composedItem [ 'email' ] [ 'email' ] ] , 'merge_vars' => $ composedItem [ 'merge_vars' ] , 'double_optin' => false , 'update_existing' => tru...
Make single signup submission to MailChimp . Typically used for resubscribes .
230,887
public function composeSubscriberSubmission ( $ newSubscribers = [ ] ) { $ composedSubscriberList = [ ] ; foreach ( $ newSubscribers as $ newSubscriberCount => $ newSubscriber ) { if ( isset ( $ newSubscriber [ 'birthdate' ] ) && is_int ( $ newSubscriber [ 'birthdate' ] ) ) { $ newSubscriber [ 'birthdate_timestamp' ] =...
Format email list to meet MailChimp API requirements for batchSubscribe
230,888
public function memberInfo ( $ email , $ listID ) { $ mailchimpStatus = $ this -> mailChimp -> call ( "/lists/member-info" , [ 'id' => $ listID , 'emails' => [ 0 => [ 'email' => $ email ] ] ] ) ; return $ mailchimpStatus ; }
Gather account information froma specific list
230,889
private function match ( $ request ) { $ route = $ this -> router -> match ( $ request -> getUri ( ) -> getPath ( ) , $ request -> getMethod ( ) ) ; if ( ! $ route ) { return $ this -> next ? $ this -> next -> __invoke ( $ request ) : null ; } return $ this -> dispatch ( $ request , $ route ) ; }
matches the route!
230,890
private function dispatch ( $ request , $ route ) { if ( $ route -> matched ( ) ) { $ request = $ request -> withPathToMatch ( $ route -> matched ( ) , $ route -> trailing ( ) ) ; } return $ this -> dispatcher -> withRoute ( $ route ) -> __invoke ( $ request ) ; }
execute the dispatcher and filters using blank new web application .
230,891
public function ParseToken ( $ text , $ startPos , & $ endPos ) { $ endPos = $ startPos + strlen ( self :: Start ) ; $ tokenString = $ this -> ExtractTokenString ( $ text , $ startPos , $ endPos ) ; if ( ! $ tokenString ) { return null ; } $ nextStop = 0 ; $ type = $ this -> ParseType ( $ tokenString , $ nextStop ) ; i...
Tries to parse a token beginning on the start marker
230,892
private function ParseFilters ( $ tokenString , $ nextStop ) { $ filters = array ( ) ; if ( $ nextStop === false ) { return $ filters ; } $ trimString = trim ( substr ( $ tokenString , $ nextStop ) ) ; if ( $ trimString == '' ) { return $ filters ; } if ( ! Str :: StartsWith ( self :: FilterSeparator , $ trimString ) )...
Parses the filters
230,893
protected function RemovalObject ( ) { $ id = Request :: PostData ( 'delete' ) ; return $ id ? Usergroup :: Schema ( ) -> ByID ( $ id ) : null ; }
The user group required for deleting
230,894
protected function CanEdit ( Usergroup $ group ) { return self :: Guard ( ) -> Allow ( BackendAction :: Edit ( ) , $ group ) && self :: Guard ( ) -> Allow ( BackendAction :: UseIt ( ) , new UsergroupForm ( ) ) ; }
True if group can be edited
230,895
protected function ModuleLockFormUrl ( Usergroup $ group ) { $ args = array ( 'usergroup' => $ group -> GetID ( ) ) ; return BackendRouter :: ModuleUrl ( new ModuleLockForm ( ) , $ args ) ; }
Gets the url for the module lock
230,896
public function behaviors ( ) { return [ 'rbac' => [ 'class' => Yii :: $ app -> cmgCore -> getRbacFilterClass ( ) , 'actions' => [ 'index' => [ 'permission' => CoreGlobal :: PERM_USER ] , 'update' => [ 'permission' => CoreGlobal :: PERM_USER ] ] ] , 'verbs' => [ 'class' => VerbFilter :: className ( ) , 'actions' => [ '...
yii \ base \ Component
230,897
public function getVariable ( $ name , $ default = NULL ) { return isset ( $ this -> conf [ $ name ] ) ? $ this -> conf [ $ name ] : $ default ; }
Returns a persistent variable .
230,898
private function getAccessTokenFromAuthorizationCode ( $ code ) { if ( $ this -> getVariable ( 'access_token_uri' ) && $ this -> getVariable ( 'client_id' ) && $ this -> getVariable ( 'client_secret' ) ) { return json_decode ( $ this -> makeRequest ( $ this -> getVariable ( 'access_token_uri' ) , 'POST' , array ( 'gran...
Get access token from OAuth2 . 0 token endpoint with authorization code .
230,899
protected function makeRequest ( $ path , $ method = 'GET' , $ params = array ( ) , $ ch = NULL ) { if ( ! $ ch ) $ ch = curl_init ( ) ; $ opts = self :: $ CURL_OPTS ; if ( $ params ) { switch ( $ method ) { case 'GET' : $ path .= '?' . http_build_query ( $ params , NULL , '&' ) ; break ; default : if ( $ this -> getVa...
Makes an HTTP request .