idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
8,400
function addBinding ( $ prop , Expression $ bindExp ) { if ( ! isset ( $ this -> bindings ) ) $ this -> bindings = [ ] ; $ this -> bindings [ $ prop ] = $ bindExp ; }
Registers a data binding .
8,401
function bind ( $ prop , $ expression ) { $ this -> bindings [ $ prop ] = $ expression instanceof Expression ? $ expression : new Expression ( $ expression ) ; }
Binds a property to a databinding expression .
8,402
function getComputedPropValue ( $ name ) { if ( isset ( $ this -> bindings [ $ name ] ) ) return $ this -> evalBinding ( $ this -> bindings [ $ name ] ) ; return $ this -> props -> get ( $ name ) ; }
Returns the current value of an attribute performing databinding if necessary .
8,403
function isPropertySet ( $ fieldName ) { return isset ( $ this -> props -> $ fieldName ) ? $ this -> props -> $ fieldName !== '' : $ this -> isBound ( $ fieldName ) ; }
Indicates if either a non - empty constant value or a databinding expression were specified for the given property .
8,404
function removeBinding ( $ prop ) { if ( isset ( $ this -> bindings ) ) { unset ( $ this -> bindings [ $ prop ] ) ; if ( empty ( $ this -> bindings ) ) $ this -> bindings = null ; } }
Removes the binding from a given property if one exists .
8,405
protected function databind ( ) { if ( isset ( $ this -> bindings ) ) foreach ( $ this -> bindings as $ attrName => $ bindExp ) { $ value = $ this -> evalBinding ( $ bindExp ) ; if ( is_object ( $ value ) ) $ this -> props -> $ attrName = $ value ; else $ this -> props -> set ( $ attrName , $ value ) ; } }
Evaluates all of the component s bindings .
8,406
protected function evalBinding ( Expression $ bindExp ) { $ binder = $ this -> getDataBinder ( ) ; if ( ! $ binder ) { _log ( ) -> warning ( "No binder is set for evaluating an expression on a " . $ this -> getTagName ( ) . " component" ) ; return null ; } try { return $ bindExp ( $ binder ) ; } catch ( \ Exception $ e...
Evaluates the given binding expression on the component s context .
8,407
protected function parseIteratorExp ( $ exp , & $ idxVar , & $ itVar ) { if ( ! preg_match ( '/^(?:(\w+):)?(\w+)$/' , $ exp , $ m ) ) throw new ComponentException ( $ this , "Invalid value for attribute <kbd>as</kbd>.<p>Expected syntax: <kbd>'var'</kbd> or <kbd>'index:var'</kbd>" ) ; list ( , $ idxVar , $ itVar ) = $ m...
Parses a component iterator property . Iterators are used by the For component for instance .
8,408
protected function createModal ( $ title , $ content = null , array $ buttons = [ ] ) { $ modal = new Modal ( $ title ) ; $ buttons = [ ] ; if ( empty ( $ buttons ) ) { $ buttons [ 'submit' ] = [ 'id' => 'submit' , 'label' => 'ekyna_core.button.save' , 'icon' => 'glyphicon glyphicon-ok' , 'cssClass' => 'btn-success' , ...
Creates a modal .
8,409
public function labelTag ( $ label = null , $ for = null ) { return '<label for="' . ( $ for ? $ for : $ this -> getID ( ) ) . '">' . ( $ label ? $ label : $ this -> label ( ) ) . '</label>' ; }
Get field s HTML label tag .
8,410
public function def ( array $ options = [ ] ) { if ( ! $ this -> widget ) throw new \ Exception ( 'No default render function for this field' ) ; return $ this -> render ( $ this -> widget , $ options ) ; }
Use the default renderer .
8,411
public function value ( ) { if ( $ this -> getOption ( 'disabled' ) ) return isset ( $ this -> options [ 'default' ] ) ? $ this -> options [ 'default' ] : null ; return $ this -> value ; }
Get the value . Can be overwritten to transform the value .
8,412
public function getID ( ) { $ parents = $ this -> getParents ( ) ; $ c = count ( $ parents ) ; if ( $ c > 0 ) { $ id = $ parents [ 0 ] . '-' ; for ( $ i = 1 ; $ i < $ c ; $ i ++ ) $ id .= $ parents [ $ i ] . '-' ; $ id .= $ this -> name ; return $ id ; } else return $ this -> name ; }
Get field id .
8,413
public static function dWithTrace ( array $ trace ) { while ( ob_get_level ( ) ) ob_end_clean ( ) ; if ( ! headers_sent ( ) ) http_response_code ( 520 ) ; if ( static :: $ format === 'html' ) echo '<pre>' ; foreach ( array_slice ( func_get_args ( ) , 1 ) as $ arg ) var_dump ( $ arg ) ; if ( static :: $ format === 'html...
Print out the backtrace and the given arguments .
8,414
public static function getReport ( array $ backtrace ) { $ r = '' ; if ( static :: $ format === 'html' ) { $ request = \ Asgard \ Http \ Request :: singleton ( ) ; $ r .= static :: getHTMLBacktrace ( $ request , $ backtrace ) ; $ r .= static :: getHTMLRequest ( $ request ) ; } else $ r .= static :: getCLIBacktrace ( $ ...
Return the HTML or CLI debug report .
8,415
protected static function getCode ( $ file , $ offset , $ limit , $ pos ) { ob_start ( ) ; highlight_string ( file_get_contents ( $ file ) ) ; $ code = ob_get_contents ( ) ; ob_end_clean ( ) ; $ code = explode ( '<br />' , $ code ) ; $ code = array_slice ( $ code , $ offset , $ limit ) ; if ( $ code ) { $ r = '<div><sp...
Return the code extract .
8,416
public static function getCLIBacktrace ( $ backtrace = null ) { if ( ! $ backtrace ) $ backtrace = debug_backtrace ( ) ; $ r = '' ; $ c = count ( $ backtrace ) ; for ( $ i = 0 ; $ i < $ c ; $ i ++ ) { $ trace = $ backtrace [ $ i ] ; if ( isset ( $ trace [ 'file' ] ) ) $ r .= $ trace [ 'file' ] . ':' . $ trace [ 'line' ...
Return the backtrace formatted for CLI .
8,417
public static function getHTMLRequest ( \ Asgard \ Http \ Request $ r ) { $ res = '<b>Request</b><br>' ; $ res .= '<div>' ; $ res .= static :: inputs ( $ r , 'get' , 'GET' ) ; $ res .= static :: inputs ( $ r , 'post' , 'POST' ) ; $ res .= static :: inputs ( $ r , 'file' , 'FILES' ) ; $ res .= static :: inputs ( $ r , '...
Return the request formatted for HTML .
8,418
protected static function inputs ( \ Asgard \ Http \ Request $ r , $ input , $ name ) { if ( $ r -> $ input -> count ( ) ) { $ res = '<div><span class="toggle"><span>+</span>' . $ name . ':</span>' ; $ res .= '<div style="display:none"><ul>' ; foreach ( $ r -> get -> all ( ) as $ k => $ v ) { $ res .= '<li>' . $ k . ':...
Return the inputs formatted for HTML .
8,419
protected static function var_dump_to_string ( $ var ) { if ( is_string ( $ var ) ) return $ var ; ob_start ( ) ; var_dump ( $ var ) ; if ( ob_get_length ( ) > 1024 ) $ str = '[' . ( is_object ( $ var ) ? get_class ( $ var ) : gettype ( $ var ) ) . ' - too big to display]' ; else $ str = ob_get_contents ( ) ; ob_end_cl...
Return var_dump output .
8,420
public function getData ( $ namespace = null ) { if ( ! self :: $ pluginData ) { if ( ! $ namespace ) { if ( property_exists ( $ this , 'namespace' ) ) { self :: $ pluginData = $ this ; } else { try { $ reflector = new \ ReflectionClass ( self :: class ) ; $ fn = $ reflector -> getFileName ( ) ; $ explode = explode ( '...
Get plugin data .
8,421
public static function config ( $ namespace ) { $ configPath = pluginsPath ( $ namespace . '/config.json' ) ; if ( file_exists ( $ configPath ) ) { return json_decode ( File :: get ( $ configPath ) ) ; } throw new \ Exception ( "No config.json file found for plugin " . $ configPath ) ; }
Get config of a plugin
8,422
public function fullBackendUrl ( ) { return url ( Config :: get ( 'project' ) [ 'adminPrefix' ] . '/' . App :: getLocale ( ) . "/plugins/" . str_replace ( "\\" , "/" , self :: config ( $ this -> namespace ) -> baseURL ) ) ; }
Full backend URL .
8,423
public function autoloadPlugins ( ) { foreach ( self :: activePlugins ( ) as $ plugin ) { if ( File :: exists ( $ plugin -> basePath ( ) . '/vendor/autoload.php' ) ) { include $ plugin -> basePath ( ) . '/vendor/autoload.php' ; } if ( File :: exists ( $ plugin -> basePath ( ) . '/support/helpers.php' ) ) { include $ pl...
Autoload all active plugins .
8,424
public function registerPlugins ( ) { foreach ( $ this -> activePlugins ( ) as $ plugin ) { $ className = $ plugin -> parseNamespace ( ) . "\\Plugin" ; if ( class_exists ( $ className ) ) { $ pluginInstance = new $ className ( ) ; if ( $ plugin -> isActive ( ) && method_exists ( $ pluginInstance , 'register' ) ) { $ pl...
Register all active plugins .
8,425
public function bootPlugins ( ) { foreach ( $ this -> activePlugins ( ) as $ plugin ) { $ className = $ plugin -> parseNamespace ( ) . "\\Plugin" ; if ( class_exists ( $ className ) ) { $ pluginInstance = new $ className ( ) ; if ( $ plugin -> isActive ( ) && method_exists ( $ pluginInstance , 'boot' ) ) { $ pluginInst...
Boot all active plugins .
8,426
public static function configs ( ) { $ files = File :: allFiles ( base_path ( ) . '/plugins' ) ; $ result = [ ] ; foreach ( $ files as $ file ) { if ( $ file -> getBasename ( ) == "config.json" ) { $ result [ ] = json_decode ( File :: get ( $ file -> getPathname ( ) ) ) ; } } return $ result ; }
Gets the config . php file of each plugins and returns their values as multidimensional array .
8,427
public function isActive ( ) { if ( ! isset ( $ this -> namespace ) ) { return false ; } if ( ! self :: isInstalled ( $ this -> namespace ) ) { return false ; } if ( ! $ this -> isActive ) { return false ; } return true ; }
Check if a plugin is active
8,428
public function toArrayRaw ( Entity $ entity , $ depth = 0 ) { $ res = [ ] ; foreach ( $ entity -> getDefinition ( ) -> properties ( ) as $ name => $ property ) { if ( $ entity -> getDefinition ( ) -> property ( $ name ) instanceof Property \ EntityProperty ) { if ( $ depth < 1 ) $ res [ $ name ] = $ entity -> get ( $ ...
Convert entity to a raw array .
8,429
public function toArray ( Entity $ entity , $ depth = 0 ) { $ res = [ ] ; foreach ( $ entity -> getDefinition ( ) -> properties ( ) as $ name => $ property ) { if ( $ entity -> getDefinition ( ) -> property ( $ name ) instanceof Property \ EntityProperty ) { if ( $ depth < 1 ) continue ; if ( $ entity -> getDefinition ...
Convert entity to a formatted array .
8,430
private function propertyToArray ( $ v , $ property ) { if ( is_null ( $ v ) ) return null ; if ( is_string ( $ v ) || is_numeric ( $ v ) || is_array ( $ v ) ) return $ v ; if ( method_exists ( $ property , 'toArray' ) ) return $ property -> toArray ( $ v ) ; elseif ( method_exists ( $ property , 'toString' ) ) return ...
Convert a property to a strig or an array .
8,431
public function toArrayRawI18N ( Entity $ entity , array $ locales = [ ] , $ depth = 0 ) { if ( ! $ locales ) $ locales = $ entity -> getLocales ( ) ; $ res = [ ] ; foreach ( $ entity -> getDefinition ( ) -> properties ( ) as $ name => $ property ) { if ( $ property -> get ( 'i18n' ) ) { foreach ( $ locales as $ locale...
Convert entity to a raw array with translations .
8,432
public function toArrayI18N ( Entity $ entity , array $ locales = [ ] , $ depth = 0 ) { if ( ! $ locales ) $ locales = $ entity -> getLocales ( ) ; $ res = [ ] ; foreach ( $ entity -> getDefinition ( ) -> properties ( ) as $ name => $ property ) { if ( $ property -> get ( 'i18n' ) ) { foreach ( $ locales as $ locale ) ...
Convert entity to a formatted array with translations .
8,433
public function toJSONI18N ( Entity $ entity , array $ locales = [ ] , $ depth = 0 ) { if ( ! $ locales ) $ locales = $ entity -> getLocales ( ) ; return json_encode ( $ entity -> toArrayI18N ( $ locales , $ depth ) ) ; }
Convert entity to JSON with translations .
8,434
public static function arrayToJSONI18N ( array $ entities , array $ locales = [ ] , $ depth = 0 ) { foreach ( $ entities as $ k => $ entity ) $ entities [ $ k ] = $ entity -> toArrayI18N ( $ locales , $ depth ) ; return json_encode ( $ entities ) ; }
Convert many entities to JSON with translations .
8,435
public static function arrayToJSON ( array $ entities , $ depth = 0 ) { foreach ( $ entities as $ k => $ entity ) $ entities [ $ k ] = $ entity -> toArray ( $ depth ) ; return json_encode ( $ entities ) ; }
Convert an array of entities to json .
8,436
public function get ( $ url ) { $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ ch , CURLOPT_SSL_VERIFYPEER , false ) ; $ content = curl_exec ( $ ch ) ; $ http_code = curl_getinfo ( $ ch , CURLINFO_HTTP_CODE ) ; if ( $ content ==...
retrieve url content
8,437
public function setLastLoginTime ( \ DateTime $ time = null ) { if ( is_null ( $ time ) ) { $ time = new \ DateTime ( ) ; } $ this -> lastLoginTime = $ time ; }
Sets user last logged in time
8,438
public function getDSN ( ) { $ dsn = [ ] ; $ map = [ 'host' => 'host' , 'port' => 'port' , 'dbname' => 'database' , 'unix_socket' => 'unix_socket' , 'charset' => 'charset' ] ; foreach ( $ map as $ dsn_name => $ data_source_parameter_name ) { if ( isset ( $ this -> data_source [ $ data_source_parameter_name ] ) ) { $ ds...
Generate the connection string .
8,439
public static function hasPosts ( $ postTypeSlug ) { $ getPostType = self :: findBySlug ( $ postTypeSlug ) ; if ( $ getPostType ) { if ( DB :: table ( $ getPostType [ 'slug' ] ) -> count ( ) > 0 ) { return true ; } } return false ; }
Check if a post type has posts .
8,440
public static function isInMenuLinks ( $ postTypeID ) { $ menulinks = MenuLink :: where ( 'belongsToID' , $ postTypeID ) -> where ( 'belongsTo' , 'post_type' ) -> count ( ) ; if ( $ menulinks ) { return true ; } return false ; }
Check if post type is being used as menulink
8,441
public static function getSlug ( $ removePrefix = false ) { $ postTypeSlug = \ Request :: route ( 'postTypeSlug' ) ; if ( ! $ postTypeSlug ) { $ url = explode ( '/' , Request :: route ( ) -> uri ( ) ) ; if ( isset ( $ url [ 0 ] ) && $ url [ 0 ] ) { $ postType = PostType :: findBySlug ( $ url [ 0 ] ) ; if ( $ postType )...
Get current post type slug .
8,442
public static function getFields ( $ post_type ) { $ postType = PostType :: all ( ) -> where ( 'slug' , $ post_type ) -> first ( ) ; if ( $ postType ) { return $ postType -> fields ; } return [ ] ; }
Get fields of a post type .
8,443
public function hasCustomController ( ) { $ controllerName = ucfirst ( str_replace ( 'post_' , '' , $ this -> slug ) ) ; if ( File :: exists ( Theme :: getPath ( ) . '/controllers/' . $ controllerName . 'Controller.php' ) ) { return true ; } return false ; }
Check if a post type has a custom controller .
8,444
public function getSyntaxHighlighterStrings ( ) { $ strings = new SyntaxHighlighterStrings ( ) ; $ strings -> setAlert ( $ this -> getTranslator ( ) -> trans ( "strings.alert" , [ ] , "WBWSyntaxHighlighterBundle" , $ this -> getTranslator ( ) -> getLocale ( ) ) ) ; $ strings -> setBrushNotHtmlScript ( $ this -> getTran...
Get a strings .
8,445
public function getSearchClosure ( ) { $ conditions = $ this -> conditions ; $ filter = function ( NodeInterface $ node ) use ( & $ conditions ) { foreach ( $ conditions as $ condition ) { $ field = $ condition [ SearchConditionInterface :: FIELD_POS ] ; $ testValue = null ; switch ( $ field ) { case SearchConditionInt...
Create closure of the search
8,446
public function getRootNodes ( ) { $ filter = new DoctrineSearchCondition ( ) ; $ filter -> levelEqualsTo ( 0 ) ; $ order = new DoctrineSelectOrder ( ) ; $ order -> byLeftAscending ( ) ; $ rootNodes = $ this -> nestedSetRepository -> search ( $ filter , $ order ) ; return $ rootNodes ; }
Get root nodes
8,447
protected function createFacade ( $ name ) { if ( preg_match ( '/^[a-zA-Z_][a-zA-Z0-9_]+$/' , $ name ) && ! class_exists ( ucfirst ( $ name ) ) ) eval ( 'class ' . ucfirst ( $ name ) . ' extends \Asgard\Container\Facade {}' ) ; }
Create a facade .
8,448
public function setEnv ( $ properties ) { $ envPath = app ( ) -> environmentFilePath ( ) ; $ contents = File :: get ( $ envPath ) ; if ( ! $ contents ) { throw new \ Exception ( 'Could not read env file' ) ; } foreach ( $ properties as $ key => $ value ) { $ this -> setEnvValue ( $ key , $ value ) ; $ contents = preg_r...
Write env file configuration
8,449
public function addTag ( TagInterface $ tag ) { if ( ! $ this -> tags -> contains ( $ tag ) ) { $ this -> tags -> add ( $ tag ) ; } return $ this ; }
Adds the tag .
8,450
public function removeTag ( TagInterface $ tag ) { if ( $ this -> tags -> contains ( $ tag ) ) { $ this -> tags -> removeElement ( $ tag ) ; } return $ this ; }
Removes the tag .
8,451
protected function getPropertyField ( \ Asgard \ Entity \ Entity $ entity , $ name , \ Asgard \ Entity \ Property $ property , $ locale = null ) { $ field = $ this -> getentityFieldSolver ( ) -> solve ( $ property ) ; if ( $ field instanceof \ Asgard \ Form \ DynamicGroup ) { $ field -> setCallback ( function ( ) use (...
Get the field for a property .
8,452
protected function getEntityFieldOptions ( \ Asgard \ Entity \ Property $ property ) { $ options = $ property -> getFormParameters ( ) ; $ options [ 'form' ] = $ this ; return $ options ; }
Get the options of a property .
8,453
protected function getDefaultValue ( \ Asgard \ Entity \ Entity $ entity , $ name , $ property , $ locale ) { if ( $ entity -> get ( $ name , $ locale ) !== null ) return $ entity -> get ( $ name , $ locale ) ; }
Get the default value of a property .
8,454
protected function myErrors ( $ validationGroups = [ ] ) { $ data = $ this -> data ( ) ; $ data = array_filter ( $ data , function ( $ v ) { if ( $ v instanceof \ Asgard \ Http \ HttpFile && $ v -> error ( ) ) return false ; return $ v !== null ; } ) ; if ( $ cb = $ this -> preEntitySetCallback ) $ cb ( $ this , $ data...
Return its own errors .
8,455
public function DelSubCommunity ( string $ tag = NULL ) { if ( GnUtil :: IsNullOrEmpty ( $ tag ) ) { throw new \ InvalidArgumentException ( "tag required" ) ; } $ this -> ExecuteCall ( "DelSubCommunity" , ( object ) [ "tag" => $ tag ] , GnResponseType :: Json , FALSE , PHP_INT_MAX ) ; }
Deletes an existing sub - community from a web - community .
8,456
public function UpdateCommunityWeb ( string $ tag = NULL , array $ hosts = [ ] , string $ mashupTokenCallbackUrl = NULL ) { if ( GnUtil :: IsNullOrEmpty ( $ tag ) ) { throw new \ InvalidArgumentException ( "tag required" ) ; } $ this -> ExecuteCall ( "UpdateCommunityWeb" , ( object ) [ "tag" => $ tag , "hosts" => $ hos...
Updates a web - community .
8,457
public function authenticate ( $ grantType = 'client_credentials' ) { if ( $ grantType == 'client_credentials' ) { $ cc = new oAuthClientCredentials ; $ this -> authorization = $ cc -> clientCredentials ( ) ; } elseif ( $ grantType = 'authorization_code' ) { $ this -> authorization = new oAuthAuthorizationCode ( ) ; } ...
Authenticate to the API and get a token
8,458
protected function sendData ( $ verb , $ parameters ) { $ endpoint = $ this -> buildEndpoint ( ) ; $ this -> buildHttpHeader ( ) ; $ client = new Client ( ) ; $ error = true ; try { $ response = $ client -> request ( $ verb , $ endpoint , $ parameters ) ; $ error = false ; } catch ( \ GuzzleException $ e ) { $ this -> ...
Execute a PUT or POST request
8,459
protected function setGetCurlopts ( ) { $ curlopts = [ CURLOPT_HTTPHEADER => $ this -> headers , CURLOPT_POST => 0 , CURLOPT_HEADER => 0 , CURLOPT_SSL_VERIFYPEER => false , CURLOPT_VERBOSE => false , CURLOPT_RETURNTRANSFER => true ] ; return $ curlopts ; }
Set the cUrl Options for a get request
8,460
protected function setPostCurlopts ( ) { $ curlopts = [ CURLOPT_HTTPHEADER => $ this -> headers , CURLOPT_POST => 1 , CURLOPT_POSTFIELDS => $ this -> postFields , CURLOPT_HEADER => 0 , CURLOPT_SSL_VERIFYPEER => false , CURLOPT_VERBOSE => false , CURLOPT_RETURNTRANSFER => true ] ; return $ curlopts ; }
Set the cUrl Options for a PUT request
8,461
public function createRelative ( $ uri = null ) { if ( empty ( $ uri ) ) { return $ this -> baseUrl ; } elseif ( substr ( $ uri , 0 , 7 ) == "http://" || substr ( $ uri , 0 , 8 ) == "https://" || substr ( $ uri , 0 , 2 ) == "//" ) { return rtrim ( $ uri , '/' ) ; } elseif ( $ uri [ 0 ] == '/' ) { return rtrim ( $ this ...
Create an url and prepend the baseUrl to the directory of the frontcontroller .
8,462
public function asset ( $ uri = null ) { if ( empty ( $ uri ) ) { } elseif ( substr ( $ uri , 0 , 7 ) == "http://" || substr ( $ uri , 0 , 8 ) == "https://" || substr ( $ uri , 0 , 2 ) == "//" ) { return rtrim ( $ uri , '/' ) ; } elseif ( $ uri [ 0 ] == '/' ) { return rtrim ( $ this -> staticSiteUrl . rtrim ( $ uri , '...
Create an url for a static asset .
8,463
public function setUrlType ( $ type ) { if ( ! in_array ( $ type , [ self :: URL_APPEND , self :: URL_CLEAN ] ) ) { throw new \ Exception ( "Unsupported Url type." ) ; } $ this -> urlType = $ type ; return $ this ; }
Set the type of urls to be generated URL_CLEAN URL_APPEND .
8,464
private function validateNested ( array $ errors ) : array { foreach ( $ this -> getFields ( false ) as $ index => $ value ) { if ( isset ( $ errors [ $ index ] ) ) { continue ; } if ( $ value instanceof FilterInterface && ! $ value -> isValid ( ) ) { $ errors [ $ index ] = $ value -> getErrors ( ) ; continue ; } if ( ...
Validate inner entities .
8,465
public function moveAction ( Request $ request ) { $ repository = $ this -> container -> getDoctrine ( ) -> getManager ( ) -> getRepository ( FileAbstraction :: CN ( ) ) ; $ repository -> getNestedSetRepository ( ) -> lock ( ) ; $ file = $ this -> getEntity ( ) ; $ parentId = $ request -> get ( 'parent_id' ) ; $ target...
Moving currently only for folders
8,466
public function saveAction ( Request $ request ) { $ file = $ this -> getEntity ( ) ; if ( $ request -> request -> has ( 'private' ) ) { $ private = $ request -> request -> get ( 'private' ) ; if ( $ private == 0 ) { $ this -> getFileStorage ( ) -> setPublic ( $ file ) ; } if ( $ private == 1 ) { $ this -> getFileStora...
Used for folder or file renaming
8,467
public function viewAction ( ) { $ node = $ this -> getFile ( ) ; $ nodeOutput = $ this -> imageAndFileOutput ( $ node ) ; $ output = array ( $ nodeOutput ) ; $ return = array ( 'totalRecords' => count ( $ output ) , 'records' => $ output , ) ; return new SupraJsonResponse ( $ return ) ; }
Used for view file or image information
8,468
public function insertAction ( Request $ request ) { $ manager = $ this -> container -> getDoctrine ( ) -> getManager ( ) ; $ repository = $ manager -> getRepository ( FileAbstraction :: CN ( ) ) ; $ repository -> getNestedSetRepository ( ) -> lock ( ) ; $ manager -> beginTransaction ( ) ; try { if ( ! $ request -> req...
Creates new folders despite it s name
8,469
public function deleteAction ( ) { $ repository = $ this -> container -> getDoctrine ( ) -> getManager ( ) -> getRepository ( FileAbstraction :: CN ( ) ) ; $ repository -> getNestedSetRepository ( ) -> lock ( ) ; $ file = $ this -> getEntity ( ) ; $ this -> checkActionPermission ( $ file , FileAbstraction :: PERMISSION...
Deletes file or folder
8,470
public function listAction ( Request $ request ) { $ rootNodes = array ( ) ; $ repo = $ this -> container -> getDoctrine ( ) -> getManager ( ) -> getRepository ( 'Supra\Package\Cms\Entity\Abstraction\File' ) ; $ output = array ( ) ; if ( $ request -> query -> get ( 'id' ) ) { $ node = $ this -> getFolder ( 'id' ) ; $ r...
Lists filesystem objects
8,471
protected function getEntityType ( FileAbstraction $ entity ) { $ type = null ; if ( $ entity instanceof Folder ) { $ type = self :: TYPE_FOLDER ; } elseif ( $ entity instanceof Image ) { $ type = self :: TYPE_IMAGE ; } elseif ( $ entity instanceof File ) { $ type = self :: TYPE_FILE ; } return $ type ; }
Get internal file entity type constant
8,472
public static function registerSchema ( $ schemaName , $ schemaClass ) { self :: $ schemaClasses [ $ schemaName ] = $ schemaClass ; self :: $ modelClassesCache = null ; self :: $ modelNamesCache = null ; self :: $ relationshipCache = null ; }
Registers a schema class to provide the schema for a given schema name .
8,473
public static function getModel ( $ modelName , $ uniqueIdentifier = null ) { $ class = self :: getModelClass ( $ modelName ) ; $ model = new $ class ( $ uniqueIdentifier ) ; return $ model ; }
Gets an empty model of the appropriate type for a given model name .
8,474
public static function getAllSchemas ( ) { foreach ( self :: $ schemaClasses as $ schemaName => $ schemaClass ) { self :: getSchema ( $ schemaName ) ; } return self :: $ schemas ; }
Returns an array of all schema objects registered .
8,475
public static function getAllRelationshipsForModel ( $ modelClassName ) { $ modelClassName = self :: getModelClass ( $ modelClassName ) ; if ( ! isset ( self :: $ relationshipCache [ $ modelClassName ] ) ) { $ schemas = self :: getAllSchemas ( ) ; $ relationships = [ ] ; foreach ( $ schemas as $ schema ) { if ( isset (...
Returns all registered relationships for a given model from all registered schemas .
8,476
public static function getAllOneToOneRelationshipsForModelBySourceColumnName ( $ modelClassName ) { $ relationships = self :: getAllRelationshipsForModel ( $ modelClassName ) ; $ columnRelationships = [ ] ; foreach ( $ relationships as $ relationship ) { if ( $ relationship instanceof OneToOne ) { $ columnName = $ rela...
Gets all the one to one relationships for a model in an array keyed by the column name in the source model .
8,477
public static function getModelClass ( $ name ) { if ( stripos ( $ name , "\\" ) !== false ) { $ newName = self :: getModelNameFromClass ( $ name ) ; if ( $ newName === null ) { return '\\' . ltrim ( $ name , '\\' ) ; } $ name = $ newName ; } if ( self :: $ modelClassesCache == null ) { self :: $ modelClassesCache = [ ...
Gets the full class name of a model using it s model name .
8,478
public function declareOneToManyRelationships ( $ relationships ) { if ( ! is_array ( $ relationships ) ) { throw new RelationshipDefinitionException ( "DefineOneToManyRelationships must be passed an array" ) ; } foreach ( $ relationships as $ oneModel => $ definitions ) { $ oneModelColumnName = "" ; if ( stripos ( $ o...
Defines one or more one - to - many relationships in an array structure .
8,479
protected function declareOneToOneRelationship ( $ sourceModelName , $ targetModelName , $ sourceColumnName , $ targetColumnName , $ navigationPropertyName = "" ) { $ oneToOne = new OneToOne ( $ navigationPropertyName , $ sourceModelName , $ sourceColumnName , $ targetModelName , $ targetColumnName ) ; $ navigationProp...
Defines a one to one relationship from the source to the target model .
8,480
protected function declareOneToManyRelationship ( $ oneModelName , $ oneColumnName , $ oneNavigationName , $ manyModelName , $ manyColumnName = "" , $ manyNavigationName = "" ) { $ oneToMany = new OneToMany ( $ oneNavigationName , $ oneModelName , $ oneColumnName , $ manyModelName , $ manyColumnName ) ; $ this -> addRe...
Defines a one to many relationship and a one to one reverse relationship .
8,481
public function getRelationship ( $ modelName , $ navigationName ) { $ modelName = $ this -> getModelClass ( $ modelName ) ; if ( ! isset ( $ this -> relationships [ $ modelName ] ) ) { return null ; } if ( ! isset ( $ this -> relationships [ $ modelName ] [ $ navigationName ] ) ) { return null ; } return $ this -> rel...
Finds and returns a relationship object on a model matching a given navigation name .
8,482
public function checkModelSchemas ( $ oldVersion = null ) { Model :: clearAllRepositories ( ) ; foreach ( $ this -> models as $ class ) { $ object = new $ class ( ) ; $ repository = $ object -> getRepository ( ) ; $ schema = $ repository -> getRepositorySchema ( ) ; $ schema -> checkSchema ( $ repository ) ; $ class ::...
Asks all registered models to check if the back end schema needs corrected .
8,483
public function renderTitle ( $ tag = 'h1' , $ content = null ) { if ( null === $ content && null !== $ page = $ this -> getPage ( ) ) { $ content = $ page -> getTitle ( ) ; $ this -> tagManager -> addTags ( $ page -> getEntityTag ( ) ) ; } if ( 0 == strlen ( $ content ) ) { $ content = 'Undefined title' ; } return $ t...
Returns current page s title .
8,484
public function renderMenu ( $ name , array $ options = [ ] , $ renderer = null ) { if ( null === $ menu = $ this -> menuProvider -> findByName ( $ name ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Menu named "%s" not found.' , $ name ) ) ; } $ this -> tagManager -> addTags ( [ Menu :: getEntityTagPrefix ( )...
Renders the menu by his name .
8,485
public function renderLocaleSwitcher ( \ Twig_Environment $ twig , array $ options = [ ] ) { if ( ! $ this -> localeSwitcher -> hasResource ( ) ) { $ this -> localeSwitcher -> setResource ( $ this -> getPage ( ) ) ; } $ options = array_replace ( [ 'dropdown' => true , 'tag' => 'div' , 'attr' => [ ] , 'locales' => [ ] ,...
Renders the locale switcher .
8,486
public function getPageControllerTitle ( $ name ) { if ( ! array_key_exists ( $ name , $ this -> config [ 'page' ] [ 'controllers' ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Undefined controller "%s".' , $ name ) ) ; } return $ this -> config [ 'page' ] [ 'controllers' ] [ $ name ] [ 'title' ] ; }
Returns the page controller title .
8,487
private function renderTag ( $ tag , $ content = null , array $ attributes = [ ] ) { $ attr = [ ] ; foreach ( $ attributes as $ key => $ value ) { $ attr [ ] = sprintf ( ' %s="%s"' , $ key , $ value ) ; } if ( 0 < strlen ( $ content ) ) { return sprintf ( '<%s%s>%s</%s>' , $ tag , implode ( '' , $ attr ) , $ content , ...
Renders the html tag .
8,488
public function filterModelsByIdentifier ( $ uniqueIdentifiers ) { $ this -> filteredIds = array_merge ( $ this -> filteredIds , $ uniqueIdentifiers ) ; $ this -> filteredCount = count ( $ this -> filteredIds ) ; }
Excludes the array of identifiers from the list of selected rows .
8,489
private function processHydration ( & $ row ) { if ( ! count ( $ this -> hydrationMappings ) ) { return ; } $ primaryFields = [ ] ; $ rawData = [ ] ; foreach ( $ row as $ key => $ value ) { if ( isset ( $ this -> hydrationMappings [ $ key ] ) ) { unset ( $ row [ $ key ] ) ; $ primary = $ this -> hydrationMappings [ $ k...
Takes a row with hydrated data and extracts it from the array .
8,490
public function renderImage ( MediaInterface $ image , array $ columns , array $ attr = [ ] ) { if ( ! $ image -> getType ( ) === MediaTypes :: IMAGE ) { throw new InvalidArgumentException ( "Expected 'image' media type." ) ; } $ map = [ ] ; $ col = 12 ; foreach ( array_reverse ( Bootstrap3Adapter :: getDevices ( ) , t...
Renders the image as responsive .
8,491
public function setsTabs ( $ tabs ) { if ( is_array ( $ tabs ) ) { $ tabs = new ArrayCollection ( $ tabs ) ; } if ( ! $ tabs instanceof ArrayCollection ) { throw new \ UnexpectedValueException ( "Expected array or instance of " . ArrayCollection :: class ) ; } $ this -> tabs = $ tabs ; return $ this ; }
Sets the tabs .
8,492
public function hasButton ( ) { if ( ! empty ( $ this -> getButtonLabel ( ) ) ) { return true ; } foreach ( $ this -> tabs as $ tab ) { if ( ! empty ( $ tab -> getButtonLabel ( ) ) ) { return true ; } } return false ; }
Returns whether the tabs needs a button .
8,493
public function isAnchorMode ( ) { foreach ( $ this -> tabs as $ tab ) { if ( ! empty ( $ tab -> getAnchor ( ) ) ) { return true ; } } return false ; }
Returns whether the tabs
8,494
static function toBoolean ( $ v ) { return is_string ( $ v ) ? get ( self :: $ BOOLEAN_VALUES , $ v , false ) : boolval ( $ v ) ; }
Converts a boolean textual representation into a true boolean value .
8,495
static function validate ( $ type , $ v ) { if ( is_null ( $ v ) || $ v === '' ) return true ; switch ( $ type ) { case type :: binding : return is_string ( $ v ) ; case type :: any : case type :: bool : return true ; case type :: data : return is_array ( $ v ) || is_object ( $ v ) || $ v instanceof \ Traversable || ( ...
Validates a value against a specific type .
8,496
private function canInstall ( ) { $ this -> info ( "Validating" ) ; if ( ! file_exists ( pluginsPath ( $ this -> pluginNamespace ) ) ) { throw new \ Exception ( "Plugin " . $ this -> pluginNamespace . " not found in plugins directory!" ) ; } exec ( 'composer dump-autoload' , $ output , $ return_var ) ; $ this -> callSi...
Checks if a plugin can be installed
8,497
private function cleanTmp ( ) { $ directories = File :: directories ( tmpPath ( ) ) ; foreach ( $ directories as $ directory ) { File :: deleteDirectory ( $ directory ) ; } return $ this ; }
Clean tmp directories
8,498
private function readConfigFile ( ) { $ this -> info ( "Reading config" ) ; if ( file_exists ( $ this -> tmpDirectory . '/config.json' ) ) { $ this -> configContent = json_decode ( File :: get ( $ this -> tmpDirectory . '/config.json' ) ) ; return $ this ; } $ directories = File :: directories ( $ this -> tmpDirectory ...
Readon installing plugin s config file
8,499
private function getZip ( ) { $ this -> info ( "Downloading" ) ; $ sourceContent = file_get_contents ( $ this -> argument ( 'source' ) ) ; if ( ! $ sourceContent ) { throw new \ Exception ( 'Source could not be found!' ) ; } $ this -> tmpRandomName = time ( ) ; $ this -> tmpZipFile = tmpPath ( $ this -> tmpRandomName ....
Get zip from source