idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
228,800
final protected function loadJs ( $ src , $ fromTheme = false , $ once = false ) { if ( $ once && ! $ this -> canLoadAsset ( $ src , 'js' ) ) return null ; return '<script type="text/javascript" src="' . $ this -> getFile ( $ src . '.js' , $ fromTheme ) . '"></script>' . "\n" ; }
Loads a javascript file
228,801
final protected function loadIcon ( $ src , $ fromTheme = false , $ once = true ) { if ( $ once && ! $ this -> canLoadAsset ( $ src , 'icon' ) ) return null ; return '<link rel="shortcut icon" href="' . $ this -> getFile ( $ src , $ fromTheme ) . '"/>' . "\n" ; }
Loads the icon for the page
228,802
final protected function canLoadAsset ( $ file , $ type ) { $ filename = basename ( $ file ) ; if ( in_array ( $ filename , $ this -> loadedAssets [ $ type ] ) ) return false ; $ this -> loadedAssets [ $ type ] [ ] = $ filename ; return true ; }
Checks if the asset has not been loaded before
228,803
final public function url ( $ module , $ controller = null , $ action = null , array $ params = array ( ) , $ hash = null ) { return $ this -> view -> url ( $ module , $ controller , $ action , $ params , $ hash ) ; }
Fetches the url path the a resource
228,804
public function getId ( ) { return base64_encode ( $ this -> path . implode ( '' , $ this -> parameters ) . implode ( '' , $ this -> body ) . $ this -> method ) ; }
Return an id unique for this request with identical parameters
228,805
public function returnWebServiceSerialisableData ( ) { $ serialisableMap = $ this -> __getSerialisablePropertyMap ( ) ; unset ( $ serialisableMap [ "trace" ] ) ; unset ( $ serialisableMap [ "file" ] ) ; unset ( $ serialisableMap [ "line" ] ) ; unset ( $ serialisableMap [ "traceAsString" ] ) ; unset ( $ serialisableMap ...
Return web service serialisable data
228,806
protected function redirectToLanguage ( $ language ) { $ result = parent :: parseRequest ( $ this -> _request ) ; if ( $ result === false ) { throw new NotFoundHttpException ( Yii :: t ( 'yii' , 'Page not found.' ) ) ; } list ( $ route , $ params ) = $ result ; if ( $ language ) { $ params [ $ this -> languageParam ] =...
Redirect to the current URL with given language code applied
228,807
public function getSubRoles ( Role $ role ) { $ parentName = $ role -> getRoleName ( ) ; $ subRoles = [ ] ; if ( array_key_exists ( $ role -> getRoleName ( ) , $ this -> mappedRoleNames ) ) { foreach ( $ this -> mappedRoleNames [ $ parentName ] as $ subRoleName ) { $ subRoles [ ] = new Role ( $ subRoleName ) ; } } retu...
get all possible sub roles of a role
228,808
private function buildRoleMap ( ) { $ this -> mappedRoleNames = [ ] ; foreach ( $ this -> hierarchy as $ parent => $ roles ) { $ roles = array_map ( 'strtolower' , $ roles ) ; $ this -> mappedRoleNames [ $ parent ] = $ roles ; $ additionalRoles = $ roles ; $ foundParent = [ ] ; while ( $ role = array_shift ( $ addition...
build the map which maps all sub - roles on any level to any of their parent roles
228,809
protected function _reset ( ) { $ tracker = $ this -> _getTracker ( ) ; $ this -> _resetTracker ( $ tracker ) ; $ iteration = $ this -> _createIterationFromTracker ( $ tracker ) ; return $ iteration ; }
Resets the loop and calculates the first iteration .
228,810
protected function _loop ( ) { $ tracker = $ this -> _getTracker ( ) ; $ this -> _advanceTracker ( $ tracker ) ; $ iteration = $ this -> _createIterationFromTracker ( $ tracker ) ; return $ iteration ; }
Advances the loop and calculates the next iteration .
228,811
final protected static function _readHeaders ( ) { if ( empty ( static :: $ _request_headers ) ) { $ headers = function_exists ( 'getallheaders' ) ? getallheaders ( ) : [ ] ; $ keys = array_keys ( $ headers ) ; array_walk ( $ keys , [ __CLASS__ , '_cleanHeader' ] ) ; static :: $ _request_headers = array_combine ( $ key...
Protected method to get the headers array cleaned for usage with magic methods
228,812
protected function doMapping ( $ source , $ targetType , PropertyMappingConfigurationInterface $ configuration , & $ currentPropertyPath ) { if ( $ source === null ) { return null ; } $ typeConverter = $ this -> getTypeConverter ( $ source , $ targetType , $ configuration ) ; $ targetType = ltrim ( $ typeConverter -> g...
Will recursively fill all the properties of the configuration object .
228,813
protected function convertChildProperties ( array $ source , $ targetType , TypeConverterInterface $ typeConverter , PropertyMappingConfigurationInterface $ configuration , array & $ currentPropertyPath ) { $ convertedChildProperties = [ ] ; $ properties = $ source ; if ( Core :: get ( ) -> classExists ( $ targetType )...
Will convert all the properties of the given source depending on the target type .
228,814
protected function handleDataPreProcessor ( $ source , $ targetType , $ currentPropertyPath ) { if ( $ this -> serviceFactory -> has ( ServiceInterface :: SERVICE_DATA_PRE_PROCESSOR ) ) { $ dataProcessorService = $ this -> serviceFactory -> get ( ServiceInterface :: SERVICE_DATA_PRE_PROCESSOR ) ; $ processor = $ dataPr...
Will check if the target type is a class then call functions which will check the interfaces of the class .
228,815
protected function getTypeConverter ( $ source , $ targetType , $ configuration ) { $ compositeType = $ this -> parseCompositeType ( $ targetType ) ; if ( in_array ( $ compositeType , [ '\\ArrayObject' , 'array' ] ) ) { $ typeConverter = $ this -> objectManager -> get ( ArrayConverter :: class ) ; } else { $ typeConver...
This function will fetch the type converter which will convert the source to the requested target type .
228,816
protected function getProperties ( $ targetType ) { $ properties = ReflectionService :: get ( ) -> getClassReflection ( $ targetType ) -> getProperties ( ) ; $ propertiesKeys = array_map ( function ( PropertyReflection $ propertyReflection ) { return $ propertyReflection -> getName ( ) ; } , $ properties ) ; return arr...
Internal function that fetches the properties of a class .
228,817
public function register ( $ entityClass , $ repositoryClass ) { $ entityName = \ Bond \ get_unqualified_class ( $ entityClass ) ; if ( isset ( $ this -> names [ $ entityName ] ) ) { throw new EntityAlreadyRegisteredException ( $ entityClass , $ repositoryClass , $ this ) ; } $ this -> names [ $ entityName ] = $ entity...
Register a entity .
228,818
function MkdirForFile ( $ filename , & $ error = null , & $ error_str = null ) { $ directory = preg_replace ( '/[^\/]+$/' , '' , $ filename ) ; if ( ! strlen ( $ directory ) ) { $ error = true ; $ error_str = "can't determine directory name" ; return ; } return self :: Mkdir ( $ directory , $ error , $ error_str ) ; }
Created a directory for the given filename .
228,819
static function CopyFile ( $ from_file , $ to_file , & $ error = null , & $ error_str = null ) { $ bytes = 0 ; $ error = false ; $ error_str = "" ; settype ( $ from_file , "string" ) ; settype ( $ to_file , "string" ) ; $ in = fopen ( $ from_file , "r" ) ; if ( ! $ in ) { $ error = true ; $ error_str = "can't open inpu...
Creates a copy of a file .
228,820
static function AppendToFile ( $ file , $ content , & $ error = null , & $ error_str = null ) { return Files :: WriteToFile ( $ file , $ content , $ error , $ error_str , array ( "file_open_mode" => "a" ) ) ; }
Appends content to the given file .
228,821
static function IsUploadedFile ( $ filename ) { settype ( $ filename , "string" ) ; if ( ! file_exists ( $ filename ) ) { return false ; } if ( is_dir ( $ filename ) ) { return false ; } if ( ! is_uploaded_file ( $ filename ) ) { return false ; } if ( fileowner ( $ filename ) != posix_getuid ( ) && ! fileowner ( $ file...
Checks if a file was uploaded via HTTP POST request .
228,822
static function MoveFile ( $ from_file , $ to_file , & $ error = null , & $ error_str = null ) { $ error = false ; $ error_str = "" ; settype ( $ from_file , "string" ) ; settype ( $ to_file , "string" ) ; if ( is_dir ( $ to_file ) && file_exists ( $ from_file ) && ! is_dir ( $ from_file ) ) { preg_match ( '/([^\/]+)$/...
Moves a file or a directory
228,823
static function Unlink ( $ file , & $ error = null , & $ error_str = null ) { $ error = false ; $ error_str = "" ; if ( ! file_exists ( $ file ) ) { return 0 ; } $ stat = unlink ( $ file ) ; if ( ! $ stat ) { $ error = true ; $ error_str = "cannot unlink $file" ; return 0 ; } return 1 ; }
Removes a file from filesystem .
228,824
static function _RecursiveUnlinkDir ( $ dir , & $ error , & $ error_str ) { settype ( $ dir , "string" ) ; $ out = 0 ; if ( $ error ) { return $ out ; } if ( $ dir == "" ) { return ; } if ( $ dir [ strlen ( $ dir ) - 1 ] == "/" ) { $ dir = preg_replace ( '/\/$/' , '' , $ dir ) ; } if ( $ dir == "" ) { return ; } if ( !...
Internal method making main part of RecursiveUnlinkDir call
228,825
static function GetFileContent ( $ filename , & $ error = null , & $ error_str = null ) { $ error = false ; $ error_str = "" ; $ out = "" ; settype ( $ filename , "string" ) ; if ( ! is_file ( $ filename ) ) { $ error = true ; $ error_str = "$filename is not a file" ; return null ; } $ filesize = filesize ( $ filename ...
Reads content of a file .
228,826
static function IsReadableAndWritable ( $ filename , & $ error = null , & $ error_str = null ) { $ error = false ; $ error_str = "" ; settype ( $ filename , "string" ) ; if ( ! file_exists ( $ filename ) ) { $ error = true ; $ error_str = "file does't exist" ; return 0 ; } $ _UID_ = posix_getuid ( ) ; $ _FILE_OWNER = f...
Checks if a file is both readable and writable .
228,827
static function GetImageSize ( $ image_content , & $ error = null , & $ error_str = null ) { $ temp = defined ( "TEMP" ) ? TEMP : "/tmp" ; $ filename = $ temp . "/get_image_filename_" . posix_getpid ( ) ; if ( ! Files :: WriteToFile ( $ filename , $ image_content , $ error , $ error_str ) ) { return null ; } $ out = ge...
Determines width and height of an image in parameter .
228,828
static function WriteToTemp ( $ content , & $ error = null , & $ error_str = null ) { $ temp_filename = Files :: GetTempFilename ( ) ; $ out = Files :: WriteToFile ( $ temp_filename , $ content , $ error , $ error_str ) ; if ( ! $ error ) { return $ temp_filename ; } }
Write a content to a temporary file .
228,829
static function GetTempDir ( ) { $ temp_dir = ( defined ( "TEMP" ) && strlen ( "TEMP" ) ) ? ( string ) TEMP : sys_get_temp_dir ( ) ; if ( ! strlen ( $ temp_dir ) ) { $ temp_dir = "/tmp" ; } return $ temp_dir ; }
Returns the temporary directory
228,830
static function DetermineFileType ( $ filename , $ options = array ( ) , & $ preferred_suffix = null ) { $ options += array ( "original_filename" => null , ) ; if ( ! file_exists ( $ filename ) || is_dir ( $ filename ) ) { return null ; } if ( function_exists ( "mime_content_type" ) ) { $ mime_type = mime_content_type ...
Determines the mime type of the file .
228,831
static function FindFiles ( $ directory , $ options = array ( ) ) { $ options += array ( "pattern" => null , "invert_pattern" => null , "min_mtime" => null , "max_mtime" => null , "maxdepth" => null ) ; if ( ! preg_match ( '/\/$/' , $ directory ) ) { $ directory = "$directory/" ; } $ pattern = $ options [ "pattern" ] ;...
Find files in the given directory according to a regular pattern and other criteria
228,832
public function isCallable ( ) : bool { return is_callable ( [ $ this -> namespace . $ this -> getController ( true ) , $ this -> getAction ( true ) ] ) ; }
Is this route callable?
228,833
public function orWhere ( $ first , $ operator = null , $ second = null ) { return $ this -> on ( $ first , $ operator , $ second , 'or' , true ) ; }
Add an or on where clause to the join .
228,834
public function findForPassport ( $ identifier ) { return ( new static ( ) ) -> newQuery ( ) -> orWhere ( function ( $ q ) use ( $ identifier ) { return $ q -> orWhere ( 'email' , $ identifier ) -> orWhere ( 'name' , $ identifier ) ; } ) -> where ( 'enabled' , 1 ) -> first ( ) ; }
Retrieve user for passport oauth .
228,835
public static function fetch ( $ file ) { $ url = 'http://www.freeformatter.com/mime-types-list.html' ; if ( file_exists ( $ file ) ) { return ; } $ filePointerCsv = fopen ( $ file , 'wb' ) ; $ fileHtml = \ dirname ( __FILE__ , 2 ) . '/resources/mimes.html' ; if ( ! file_exists ( $ fileHtml ) ) { $ contents = file_get_...
Convert HTML page to CSV then create Mime listings .
228,836
public static function generate ( $ file ) { $ filePointer = fopen ( $ file , 'rb' ) ; $ names = '' ; $ extensions = '' ; $ header = true ; while ( ( $ row = fgetcsv ( $ filePointer ) ) ) { if ( $ header ) { $ header = false ; continue ; } $ mime = trim ( $ row [ 0 ] ) ; $ name = trim ( addslashes ( $ row [ 1 ] ) ) ; $...
Generate FileMimes class .
228,837
public function createEntity ( $ entity , TableNode $ fields ) { $ this -> models -> get ( $ entity ) -> store ( $ fields -> getRowsHash ( ) ) ; }
Creates an entity with specified fields
228,838
public function applyFixtures ( TableNode $ fixtures ) { $ fixtures = $ fixtures -> getColumn ( 0 ) ; $ dataSet = new CompositeDataSet ( ) ; foreach ( $ fixtures as $ fixture ) { $ dataSet -> addDataSet ( $ this -> fixtures -> createMySQLXMLDataSet ( $ fixture ) ) ; } $ this -> fixtures -> applyDataSet ( $ dataSet ) ; ...
Populates a fixture into the database .
228,839
public function getClassReflections ( $ code ) { $ result = [ ] ; foreach ( $ this -> getClassNames ( $ code ) as $ className ) { $ result [ $ className ] = new \ ReflectionClass ( $ className ) ; } return $ result ; }
returns the classes form an included code .
228,840
protected function undelete ( ) { if ( $ this -> saveButtonPushed ( ) ) { $ nodeRef = $ this -> buildCmsNodeRef ( ) ; $ node = $ nodeRef -> generateNode ( ) ; $ location = 'load' ; $ this -> Events -> trigger ( 'NodeCmsController.undelete' . '.' . $ location , $ this -> errors , $ this -> templateVars , $ node ) ; fore...
Provides undelete functionality for Nodes
228,841
protected function single ( ) { $ nq = new NodeQuery ( ) ; $ nq -> setLimit ( 1 ) ; $ this -> passthruTemplateVariable ( $ nq , 'Elements.in' ) ; $ this -> passthruTemplateVariable ( $ nq , 'Sites.in' ) ; $ this -> passthruTemplateVariable ( $ nq , 'Meta.select' ) ; $ this -> passthruTemplateVariable ( $ nq , 'OutTags....
Datasource for returning a single Node
228,842
protected function items ( ) { $ dto = new NodeQuery ( ) ; $ this -> buildLimitOffset ( $ dto ) ; $ this -> passthruTemplateVariable ( $ dto , 'Elements.in' ) ; $ this -> passthruTemplateVariable ( $ dto , 'Sites.in' ) ; $ this -> passthruTemplateVariable ( $ dto , 'Slugs.in' ) ; $ this -> passthruTemplateVariable ( $ ...
Datasource for returning all matching Nodes
228,843
protected function buildCmsNodeRef ( $ slugKey = 'OriginalSlug' ) { if ( empty ( $ this -> params [ 'Element' ] ) ) throw new Exception ( 'Element parameter is required' ) ; $ nodeElement = $ this -> ElementService -> getBySlug ( $ this -> params [ 'Element' ] ) ; if ( ! is_null ( $ slugKey ) && $ this -> Request -> ge...
Given a slug builds a nodeRef
228,844
public function date ( $ date = null ) { if ( is_null ( $ date ) ) { $ date = $ this -> created_at ; } return String :: date ( $ date ) ; }
Get the date the post was created .
228,845
public function parse ( QuoteInterface $ quoting ) { $ outputSql = "" ; foreach ( $ this -> relations as $ relation ) { $ columns = array ( ) ; foreach ( $ relation -> getPrimaryKeys ( ) as $ column ) { $ columns [ $ column -> get ( 'name' ) ] = $ column -> getType ( ) -> getTypeQuery ( ) ; } if ( $ this -> notificatio...
Generate and execute sql which will attach notification triggers to relations
228,846
public function donovan ( QuoteInterface $ quoting , $ prefix , $ columns ) { $ sql = array ( ) ; foreach ( $ columns as $ column => $ type ) { $ sql [ ] = sprintf ( 'donovan(%s%s)' , $ prefix , $ quoting -> quoteIdent ( $ column ) ) ; } return sprintf ( "'['||%s||']'" , implode ( "||','||" , $ sql ) ) ; }
Produce a sql statement which resolves to a string but is a valid json
228,847
private function catalogRefresh ( ) { Relation :: r ( ) -> preload ( ) ; Attribute :: r ( ) -> preload ( ) ; Type :: r ( ) -> preload ( ) ; Index :: r ( ) -> preload ( ) ; }
Refresh the catalog
228,848
public function validate ( Request $ request , array $ rules = [ ] , array $ filters = [ ] ) { $ all = $ request -> all ( ) ; return $ request -> getValidation ( ) -> make ( $ all , $ rules , $ filters ) ; }
validate the form
228,849
public function encrypt ( $ value , $ iv = null ) { if ( empty ( $ value ) ) return false ; include_once PATH_SYSTEM . '/vendors/phpseclib0/Crypt/Rijndael.php' ; include_once PATH_SYSTEM . '/vendors/phpseclib0/Crypt/AES.php' ; $ this -> Crypt = new Crypt_AES ( ) ; $ this -> Crypt -> setKey ( $ this -> key ) ; if ( ! is...
Encrypts the given value using the included phpseclib AES implementation
228,850
public function decryptSecureCookie ( $ value ) { $ cookieValues = explode ( '|' , $ value , 4 ) ; if ( ( count ( $ cookieValues ) === 4 ) && ( $ cookieValues [ 1 ] == 0 || $ cookieValues [ 1 ] >= time ( ) ) ) { $ userid = $ cookieValues [ 0 ] ; $ expire = $ cookieValues [ 1 ] ; $ encrValue = $ cookieValues [ 2 ] ; $ k...
Retrieve a secured cookie value
228,851
public function encryptSecureCookie ( $ value , $ expire , $ userid = null ) { $ expire = ( strcmp ( strtolower ( $ expire ) , 'never' ) === 0 ? time ( ) + 60 * 60 * 24 * 6000 : $ expire ) ; if ( is_null ( $ userid ) ) $ userid = ( string ) $ this -> RequestContext -> getUserRef ( ) ; $ key = hash_hmac ( 'sha1' , $ use...
Secure a cookie value
228,852
abstract public function __construct ( Request $ request , $ relativeCmsUri , CmsComponent $ cmsComponent ) ;
CmsRouting constructor .
228,853
public static function isRequiredIntegerRange ( $ value , $ min , $ max ) { return is_int ( $ value ) && $ min <= $ value && $ max >= $ value ; }
Required value is integer in range .
228,854
public static function isOptionalIntegerRange ( $ value , $ min , $ max ) { if ( null === $ value ) { return true ; } return self :: isRequiredIntegerRange ( $ value , $ min , $ max ) ; }
Optional value is integer in range .
228,855
public static function isRequiredFloatRange ( $ value , $ min , $ max ) { return is_float ( $ value ) && $ min <= $ value && $ max >= $ value ; }
Required value is float in range .
228,856
public static function isOptionalFloatRange ( $ value , $ min , $ max ) { if ( null === $ value ) { return true ; } return self :: isRequiredFloatRange ( $ value , $ min , $ max ) ; }
Optional value is float in range .
228,857
public static function isOptionalNumberRange ( $ value , $ min , $ max ) { if ( null === $ value ) { return true ; } return self :: isRequiredNumberRange ( $ value , $ min , $ max ) ; }
Optional value is number in range .
228,858
public static function isRequiredNumericRange ( $ value , $ min , $ max ) { return is_numeric ( $ value ) && $ min <= $ value && $ max >= $ value ; }
Required value is numeric in range .
228,859
public static function isOptionalNumericRange ( $ value , $ min , $ max ) { if ( null === $ value ) { return true ; } return self :: isRequiredNumericRange ( $ value , $ min , $ max ) ; }
Optional value is numeric in range .
228,860
public static function isOptionalExistingKey ( $ key , array $ values ) { if ( null === $ key ) { return true ; } return self :: isRequiredExistingKey ( $ key , $ values ) ; }
Optional key exists .
228,861
public function setParams ( $ key , $ value = null ) { if ( is_array ( $ key ) ) { $ this -> params = array_merge_recursive ( $ this -> params , $ key ) ; return $ this ; } $ this -> params [ $ key ] = $ value ; return $ this ; }
Set parameter data
228,862
protected function hasRelation ( $ key , $ value , $ relations ) { if ( is_numeric ( $ relations ) ) { if ( $ relations > 0 ) { return true ; } return false ; } foreach ( $ relations as $ prop ) { if ( $ prop == 'assets' ) { if ( $ key === 'fields' || ( ! $ this -> resolved ( $ value ) && is_object ( $ value ) && prope...
Check if relation exists
228,863
protected function getNestedRelations ( $ key , $ relations ) { if ( is_numeric ( $ relations ) ) { if ( $ key == 'fields' ) { return $ relations ; } if ( $ relations - 1 > 0 ) { return $ relations - 1 ; } return [ ] ; } $ nestedRelations = [ ] ; foreach ( $ relations as $ prop ) { if ( $ prop === 'assets' ) { $ nested...
Get nested relations for field
228,864
protected function loadQueue ( ) { $ loadQueue = self :: $ loadQueue ; foreach ( $ loadQueue as $ type => $ queries ) { foreach ( $ queries as $ query ) { $ ids = [ ] ; foreach ( $ query [ 'ids' ] as $ id ) { if ( Trunk :: has ( [ $ id , $ query [ 'relations' ] ] , $ type ) ) { $ object = Trunk :: get ( [ $ id , $ quer...
Load objects from queue
228,865
public function addIncludes ( $ includes ) { if ( $ includes instanceof Model ) { $ this -> addItemToInclude ( $ includes ) ; } else { foreach ( $ includes as $ item ) { $ this -> addItemToInclude ( $ item ) ; } } if ( $ includes instanceof DataTransferObject ) { $ this -> addIncludes ( $ includes -> getIncludes ( ) ) ...
Add items to include
228,866
public function offsetSet ( $ offset , $ value ) { if ( is_null ( $ offset ) ) { if ( ! $ this -> isCollection ) { throw new Exception ( 'You need to specify a valid key for model.' ) ; } $ this -> data [ ] = $ value ; } else { if ( $ this -> isCollection ) { $ this -> data [ $ offset ] = $ value ; return ; } $ this ->...
Set data at specific offset
228,867
public function offsetExists ( $ offset ) { return ( $ this -> isCollection ) ? isset ( $ this -> data [ $ offset ] ) : isset ( $ this -> data -> { $ offset } ) ; }
Check if provided offset exists
228,868
public function offsetUnset ( $ offset ) { if ( $ this -> isCollection ) { unset ( $ this -> data [ $ offset ] ) ; } else { unset ( $ this -> data -> { $ offset } ) ; } }
Unset the provided offset
228,869
public function toJson ( $ options = 0 , $ includeMetaData = false , $ nestedInclude = true , $ callback = null ) { $ data = $ this -> toArray ( $ includeMetaData , $ nestedInclude , $ callback ) ; return json_encode ( $ data , $ options ) ; }
Get the instance as an json string .
228,870
public function transformToArray ( $ data , $ nestedInclude = true , $ extraIncludes = [ ] , $ callback = null ) { if ( is_object ( $ data ) ) { if ( $ nestedInclude && ! $ this -> resolved ( $ data ) ) { $ objectKey = $ this -> objectKey ( $ data ) ; if ( array_key_exists ( $ objectKey , $ extraIncludes ) ) { $ data =...
Convert Object to array deep
228,871
protected function resolve ( $ obj ) { if ( Trunk :: has ( $ obj -> id , $ obj -> type ) ) { return $ data = Trunk :: get ( $ obj -> id , $ obj -> type ) ; } return $ obj ; }
Get resolved object form trunk if possible
228,872
public function getIncluded ( $ obj ) { $ includes = $ this -> getIncludes ( true ) ; $ objectKey = $ this -> objectKey ( $ obj ) ; if ( array_key_exists ( $ objectKey , $ includes ) ) { return $ includes [ $ objectKey ] ; } return $ obj ; }
Get resolved object from included
228,873
protected function objectKey ( $ object ) { return base64_encode ( json_encode ( [ 'id' => $ object -> id , 'type' => $ object -> type , 'relations' => $ this -> relations ] ) ) ; }
Make base64 key from object
228,874
public function getQueues ( array $ queueAlias ) : array { $ queues = [ ] ; foreach ( $ queueAlias as $ alias ) { $ queues [ ] = $ this -> getQueue ( $ alias ) ; } return $ queues ; }
Given an array of queueAliases return a valid queueNames array .
228,875
public function getQueueAliasByQueueName ( string $ queueName ) : string { return is_array ( $ this -> queues ) ? ( ( array_flip ( $ this -> queues ) [ $ queueName ] ) ?? $ queueName ) : $ queueName ; }
Return queue alias by queue name .
228,876
public function getButton ( $ details ) { if ( is_string ( $ details ) ) { return HtmlHelper :: get ( ) -> noContentElement ( 'input' , array ( 'type' => 'submit' , 'name' => $ details , 'value' => $ this -> translate ( ucwords ( str_replace ( '_' , ' ' , $ details ) ) ) ) ) ; } if ( isset ( $ details [ 'visible' ] ) &...
Return html code for a button .
228,877
public function registerSystemServices ( ) { $ factory = Yii :: $ app -> factory -> getContainer ( ) ; $ factory -> set ( 'cmsgears\social\connect\common\services\interfaces\system\IFacebookService' , 'cmsgears\social\connect\common\services\system\FacebookService' ) ; $ factory -> set ( 'cmsgears\social\connect\common...
Registers system services .
228,878
public function registerSystemAliases ( ) { $ factory = Yii :: $ app -> factory -> getContainer ( ) ; $ factory -> set ( 'facebookService' , 'cmsgears\social\connect\common\services\system\FacebookService' ) ; $ factory -> set ( 'googleService' , 'cmsgears\social\connect\common\services\system\GoogleService' ) ; $ fact...
Registers system aliases .
228,879
protected function response ( $ result ) { $ response = $ this -> container -> get ( Application :: RESPONSE ) ; if ( $ result instanceof ResponseInterface ) { return $ result ; } $ response -> stream ( ) -> write ( $ result ) ; return $ response ; }
Converts the given result into a ResponseInterface .
228,880
public function camelize ( $ base ) { $ callback = create_function ( '$c' , 'return strtoupper($c[1]);' ) ; if ( ! is_array ( $ base ) ) { return preg_replace_callback ( '/_([a-z])/' , $ callback , $ base ) ; } foreach ( $ base as $ key => $ val ) { unset ( $ base [ $ key ] ) ; $ newKey = preg_replace_callback ( '/_([a...
Convert strings from under_scores to CamelCase .
228,881
public function uncamelize ( $ base ) { $ callback = create_function ( '$c' , 'return "_" . strtolower($c[1]);' ) ; if ( ! is_array ( $ base ) ) { $ base [ 0 ] = strtolower ( $ base [ 0 ] ) ; return preg_replace_callback ( '/([A-Z])/' , $ callback , $ base ) ; } foreach ( $ base as $ key => $ val ) { unset ( $ base [ $...
Converts strings from camelCase to under_score .
228,882
public function addIn ( $ field , $ values , $ whereConcat = 'AND' ) { if ( ! is_array ( $ values ) ) { return $ this ; } $ field = ( 0 < count ( $ this -> wheres ) ? ' ' . $ whereConcat . ' ' . $ field : $ field ) ; $ index = 1 ; $ fields = array ( ) ; foreach ( $ values as $ value ) { $ name = ':value_' . $ index ; $...
Add In list item .
228,883
public function addWhere ( $ field , $ value , $ sign = '=' , $ whereConcat = 'AND' ) { $ fieldWhere = ( 0 < count ( $ this -> wheres ) ? ' ' . $ whereConcat . ' ' . $ field : $ field ) ; $ fieldBind = ':' . strtolower ( $ field ) ; if ( isset ( $ this -> binds [ $ fieldBind ] ) ) { $ counter = 0 ; while ( $ counter < ...
Add where clause .
228,884
public function clear ( ) { $ this -> wheres = array ( ) ; $ this -> sets = array ( ) ; $ this -> havings = array ( ) ; $ this -> orders = array ( ) ; $ this -> binds = array ( ) ; $ this -> limit = null ; $ this -> offset = null ; return $ this ; }
Clear query params
228,885
public function getQueryFields ( $ usePrefix = false , $ prefix = '' ) { $ fields = $ this -> fields ; if ( $ usePrefix ) { $ prefix = ( empty ( $ prefix ) ? $ this -> getTable ( ) : $ prefix ) ; $ fields = array ( ) ; foreach ( $ this -> fields as $ field ) { $ fields [ ] = $ prefix . '.' . $ field ; } } return implod...
Get fields to select
228,886
public function getQueryLimit ( ) { if ( $ this -> limit !== null && $ this -> offset !== null ) { return 'LIMIT ' . $ this -> offset . ', ' . $ this -> limit ; } else { if ( null !== $ this -> limit ) { return 'LIMIT ' . $ this -> limit ; } else { return '' ; } } }
Get limit clause .
228,887
public function count ( $ field = '*' ) { if ( $ field !== '*' && ! in_array ( $ field , $ this -> getFields ( ) ) ) { throw new \ DomainException ( __METHOD__ . '|Field is not allowed ! (field: ' . $ field . ')' ) ; } $ query = 'SELECT COUNT(' . $ field . ') AS NB_RESULTS FROM ' . $ this -> table . ' ' . $ this -> get...
Count number of results for query .
228,888
public function rowExists ( $ field , $ value ) { $ this -> addWhere ( $ field , $ value ) ; try { $ this -> selectOne ( ) ; return true ; } catch ( ExceptionNoData $ exception ) { return false ; } }
Check if value row exists in database ..
228,889
public function query ( $ query ) { $ statement = $ this -> db -> prepare ( $ query ) ; $ statement -> execute ( $ this -> binds ) ; $ this -> clear ( ) ; $ collection = array ( ) ; while ( false !== ( $ row = $ statement -> fetchObject ( ) ) ) { $ collection [ ] = $ this -> newDataInstance ( $ row , true ) ; } return ...
Fetch rows for specified query .
228,890
public function delete ( DataAbstract $ data ) { foreach ( $ this -> primaryKeys as $ key ) { $ this -> addWhere ( $ key , $ this -> getDataValue ( $ data , $ key ) ) ; } $ where = $ this -> getQueryWhere ( ) ; if ( empty ( $ where ) ) { throw new \ LogicException ( __METHOD__ . '| Where restriction is empty for curren...
Delete data from database .
228,891
public function persist ( DataAbstract $ data ) { if ( $ data -> exists ( ) ) { return $ this -> update ( $ data ) ; } else { return $ this -> insert ( $ data ) ; } }
Persist data in database .
228,892
public function update ( DataAbstract $ data ) { if ( ! $ data -> isUpdated ( ) ) { return false ; } $ this -> binds = array ( ) ; foreach ( $ this -> primaryKeys as $ key ) { $ this -> addWhere ( $ key , $ this -> getDataValue ( $ data , $ key ) ) ; } $ set = $ this -> getQueryFieldsSet ( $ data ) ; if ( empty ( $ set...
Update data into database
228,893
public function select ( ) { $ query = 'SELECT ' . $ this -> getQueryFields ( ) . ' FROM ' . $ this -> getTable ( ) . ' ' . $ this -> getQueryWhere ( ) . ' ' . $ this -> getQueryOrderBy ( ) . ' ' . $ this -> getQueryLimit ( ) ; $ statement = $ this -> db -> prepare ( $ query ) ; $ statement -> execute ( $ this -> binds...
Select all rows corresponding of where clause .
228,894
public function selectOne ( ) { $ this -> setLimit ( 1 ) ; $ query = 'SELECT ' . $ this -> getQueryFields ( ) . ' FROM ' . $ this -> getTable ( ) . ' ' . $ this -> getQueryWhere ( ) . ' ' . $ this -> getQueryOrderBy ( ) . ' ' . $ this -> getQueryLimit ( ) ; $ statement = $ this -> db -> prepare ( $ query ) ; $ statemen...
Select first rows corresponding to where clause .
228,895
protected function getCache ( DataAbstract $ data ) { if ( ! $ this -> isCacheEnabled ) { return false ; } return $ this -> cache -> get ( $ data -> getCacheKey ( ) ) ; }
Get Data object from cache if is enabled .
228,896
protected function setCache ( DataAbstract $ data ) { if ( ! $ this -> isCacheEnabled ) { return $ this ; } $ this -> cache -> set ( $ data -> getCacheKey ( ) , $ data ) ; return $ this ; }
Set data into cache if enabled .
228,897
protected function isDataUpdated ( $ data , $ field ) { if ( ! isset ( $ this -> dataNamesMap [ $ field ] [ 'property' ] ) ) { throw new \ DomainException ( 'Field have not mapping with Data instance (field: ' . $ field . ')' ) ; } $ property = $ this -> dataNamesMap [ $ field ] [ 'property' ] ; return $ data -> isUpda...
Check if data value is updated or not
228,898
protected function getDataValue ( $ data , $ field ) { if ( ! isset ( $ this -> dataNamesMap [ $ field ] [ 'get' ] ) ) { throw new \ DomainException ( 'Field have not mapping with Data instance (field: ' . $ field . ')' ) ; } $ method = $ this -> dataNamesMap [ $ field ] [ 'get' ] ; return $ data -> { $ method } ( ) ; ...
Get value from DataAbstract instance based on field value
228,899
protected function setDataValue ( $ data , $ field , $ value ) { if ( ! isset ( $ this -> dataNamesMap [ $ field ] [ 'set' ] ) ) { if ( true === $ this -> ignoreNotMappedFields ) { return $ this ; } throw new \ DomainException ( 'Field have not mapping with Data instance (field: ' . $ field . ')' ) ; } $ method = $ thi...
Set value into DataAbstract instance based on field value