idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
43,200 | public function image ( Environment $ env , $ fileName = null , $ width = null , $ height = null , $ crop = null ) { if ( $ width && ! $ height && ! $ crop && $ this -> isAlias ( $ width ) ) { return $ this -> getAliasedUri ( $ fileName , $ width ) ; } if ( $ width || $ height ) { return $ this -> thumbnail ( $ fileNam... | Helper function to make a path to an image . |
43,201 | public function imageInfo ( $ fileName ) { if ( $ fileName instanceof ImageInterface ) { return $ fileName ; } $ image = $ this -> filesystem -> getFile ( 'files://' . $ fileName , new NullableImage ( ) ) ; return $ image ; } | Get an image . |
43,202 | public function popup ( $ fileName = null , $ width = null , $ height = null , $ crop = null , $ title = null ) { if ( empty ( $ fileName ) ) { return '' ; } $ thumbconf = $ this -> config -> get ( 'general/thumbnails' ) ; $ fullwidth = ! empty ( $ thumbconf [ 'default_image' ] [ 0 ] ) ? $ thumbconf [ 'default_image' ]... | Helper function to wrap an image in a Magnific popup HTML tag with thumbnail . |
43,203 | public function showImage ( $ fileName = null , $ width = null , $ height = null , $ crop = null ) { if ( empty ( $ fileName ) ) { return '' ; } $ thumb = $ this -> getThumbnail ( $ fileName , $ width , $ height , $ crop ) ; if ( $ width === null && $ height === null ) { $ thumbconf = $ this -> config -> get ( 'general... | Helper function to show an image on a rendered page . |
43,204 | public function thumbnail ( $ fileName = null , $ width = null , $ height = null , $ crop = null ) { if ( $ width && ! $ height && ! $ crop && $ this -> isAlias ( $ width ) ) { return $ this -> getAliasedUri ( $ fileName , $ width ) ; } $ thumb = $ this -> getThumbnail ( $ fileName , $ width , $ height , $ crop ) ; ret... | Helper function to make a path to an image thumbnail . |
43,205 | private function getThumbnail ( $ fileName = null , $ width = null , $ height = null , $ scale = null ) { $ thumb = new Thumbnail ( $ this -> config -> get ( 'general/thumbnails' ) ) ; $ thumb -> setFileName ( $ fileName ) -> setWidth ( $ width ) -> setHeight ( $ height ) -> setScale ( $ scale ) ; return $ thumb ; } | Get a thumbnail object . |
43,206 | private function getThumbnailUri ( Thumbnail $ thumb ) { $ fileName = $ thumb -> getFileName ( ) ; if ( $ fileName === null || $ fileName === '' ) { return false ; } return $ this -> urlGenerator -> generate ( 'thumb' , [ 'width' => $ thumb -> getWidth ( ) , 'height' => $ thumb -> getHeight ( ) , 'action' => $ thumb ->... | Get the thumbnail relative URI using width height and action . |
43,207 | private function getAliasedUri ( $ fileName , $ alias ) { if ( $ fileName === null ) { return false ; } if ( ! $ this -> isAlias ( $ alias ) ) { return false ; } $ fileName = $ this -> normalizeFileName ( $ fileName ) ; return $ this -> urlGenerator -> generate ( 'thumb_alias' , [ 'alias' => $ alias , 'file' => $ fileN... | Get the thumbnail relative URI using an alias . |
43,208 | public function onUserEntityPreSave ( StorageEvent $ event ) { $ entityRecord = $ event -> getContent ( ) ; if ( $ entityRecord instanceof Entity \ Users ) { $ this -> passwordHash ( $ entityRecord ) ; } } | Pre - save storage event for user entities . |
43,209 | public function onPostHydrate ( HydrationEvent $ event ) { $ entity = $ event -> getSubject ( ) ; if ( ! $ entity instanceof Entity \ Users ) { return ; } $ roles = $ entity -> getRoles ( ) ; if ( ! in_array ( Permissions :: ROLE_EVERYONE , $ roles ) ) { $ roles [ ] = Permissions :: ROLE_EVERYONE ; $ entity -> setRoles... | Post hydration storage event . |
43,210 | public function onPreDelete ( StorageEvent $ event ) { $ entity = $ event -> getContent ( ) ; if ( ! $ entity instanceof Entity \ Content ) { return ; } $ taxonomies = $ entity -> getTaxonomy ( ) ; if ( $ taxonomies instanceof Collection \ Taxonomy ) { $ repo = $ this -> em -> getRepository ( Entity \ Taxonomy :: class... | Pre - delete event to delete an entities taxonomy & relation entities . |
43,211 | protected function schemaCheck ( GetResponseEvent $ event ) { $ session = $ event -> getRequest ( ) -> getSession ( ) ; $ validSession = $ session -> isStarted ( ) && $ session -> get ( 'authentication' ) ; $ expired = $ this -> schemaManager -> isCheckRequired ( ) ; $ notInCheck = ! in_array ( $ event -> getRequest ( ... | Trigger database schema checks if required . |
43,212 | protected function passwordHash ( Entity \ Users $ usersEntity ) { if ( $ usersEntity -> getPassword ( ) !== null ) { $ usersEntity -> setPassword ( $ this -> getValidHash ( $ usersEntity -> getPassword ( ) ) ) ; } } | Hash user passwords on save . |
43,213 | private function getValidHash ( $ password ) { if ( Password \ Blowfish :: detect ( $ password ) ) { return $ password ; } if ( Password \ PHPASS :: detect ( $ password ) ) { return $ password ; } if ( strlen ( $ password ) < 6 ) { throw new AccessControlException ( 'Can not save a password with a length shorter than 6... | Return a valid hash for a password of if the password is already hashed just return as is . |
43,214 | public function run ( array $ exportContentTypes , MutableBag $ responseBag , $ includeUsers = false ) { $ exportData = MutableBag :: from ( [ ] ) ; $ this -> addExportMeta ( $ exportData ) ; if ( $ includeUsers ) { $ this -> addExportUsers ( $ exportData ) ; } foreach ( $ exportContentTypes as $ contentTypeName ) { $ ... | Run the export process and return the data . |
43,215 | private function addExportMeta ( MutableBag $ exportData ) { $ exportData -> set ( '__bolt_export_meta' , [ 'date' => Carbon :: now ( ) -> toRfc3339String ( ) , 'version' => Version :: forComposer ( ) , 'platform' => $ this -> em -> getConnection ( ) -> getDatabasePlatform ( ) -> getName ( ) , ] ) ; } | Add the export meta information . |
43,216 | private function addExportUsers ( MutableBag $ exportData ) { $ repo = $ this -> em -> getRepository ( Users :: class ) ; $ users = $ repo -> findAll ( ) ; $ export = [ ] ; foreach ( $ users as $ user ) { $ export [ ] = Bag :: from ( $ user -> toArray ( ) ) -> filter ( function ( $ k ) { return \ in_array ( $ k , [ 'id... | Add the user table to the export . |
43,217 | private function getRecords ( $ contentTypeName , MutableBag $ exportData , MutableBag $ responseBag ) { $ repo = $ this -> em -> getRepository ( $ contentTypeName ) ; $ metadata = $ repo -> getClassMetadata ( ) ; $ entities = $ this -> query -> getContent ( $ contentTypeName ) ; $ contentTypeBag = $ exportData -> get ... | Get the records for a given ContentType . |
43,218 | private function addRecord ( MutableBag $ contentTypeBag , ClassMetadata $ metadata , Content $ entity ) { $ values = [ ] ; foreach ( $ metadata -> getFieldMappings ( ) as $ field ) { $ fieldName = $ field [ 'fieldname' ] ; $ val = $ entity -> $ fieldName ; if ( in_array ( $ field [ 'type' ] , [ 'date' , 'datetime' ] )... | Add a single record to the export data . |
43,219 | public function stack ( $ types = [ ] ) { if ( is_string ( $ types ) ) { $ types = explode ( ',' , $ types ) ? : [ ] ; $ types = array_filter ( array_map ( 'trim' , $ types ) ) ; } $ files = $ this -> stack -> getList ( $ types ) ; return $ files ; } | Return an array with the items on the stack . |
43,220 | public function logLevel ( $ level ) { if ( ! is_numeric ( $ level ) ) { return $ level ; } try { return ucfirst ( strtolower ( \ Monolog \ Logger :: getLevelName ( $ level ) ) ) ; } catch ( \ Exception $ e ) { return $ level ; } } | Convert a Monolog log level to textual equivalent . |
43,221 | public function ymllink ( $ str ) { return preg_replace_callback ( '/ ([a-z0-9_-]+\.yml)/i' , function ( $ matches ) { $ path = $ this -> urlGenerator -> generate ( 'fileedit' , [ 'namespace' => 'config' , 'file' => $ matches [ 1 ] ] ) ; $ link = sprintf ( ' <a href="%s">%s</a>' , $ path , $ matches [ 1 ] ) ; return $ ... | Create a link to edit a . yml file if a filename is detected in the string . Mostly for use in Flashbag messages to allow easy editing . |
43,222 | public function hattr ( $ attributes ) { $ booleans = [ 'checked' , 'disabled' , 'multiple' , 'readonly' , 'required' , 'selected' ] ; $ return = '' ; $ add = function ( $ name , $ value = null ) use ( & $ return ) { $ return .= ' ' . $ name . ( $ value === null ? '' : '="' . htmlspecialchars ( $ value ) . '"' ) ; } ; ... | Prepares attributes ready to attach to an html tag . |
43,223 | public function hclass ( $ classes , $ raw = false ) { if ( is_array ( $ classes ) ) { $ classes = implode ( ' ' , $ classes ) ; } $ classes = preg_split ( '/ +/' , trim ( $ classes ) ) ; $ classes = implode ( ' ' , $ classes ) ; if ( $ raw ) { return $ classes ; } return $ classes ? ' class="' . htmlspecialchars ( $ c... | Generates pretty class attributes . |
43,224 | private function configureLogger ( ErrorHandler $ handler , LoggerInterface $ logger , $ loggedAt ) { $ handler -> setDefaultLogger ( $ logger , $ loggedAt ) ; $ notLoggedLevels = [ ] ; $ defaults = [ E_DEPRECATED => null , E_USER_DEPRECATED => null , E_NOTICE => null , E_USER_NOTICE => null , E_STRICT => null , E_WARN... | Configure the error handler to log types given to the logger given and to ignore all types not specified . |
43,225 | public function getSchemaTables ( Schema $ schema , Config $ config ) { if ( $ this -> tableSchemas !== null ) { return $ this -> tableSchemas ; } $ fieldManager = $ config -> getFields ( ) ; $ contentTypes = $ this -> getNormalisedContentTypes ( $ config ) ; $ tables = [ ] ; foreach ( $ this -> tables -> keys ( ) as $... | Build the schema for Bolt ContentType tables . |
43,226 | private function getNormalisedContentTypes ( Config $ config ) { $ normalised = [ ] ; $ contentTypes = $ config -> get ( 'contenttypes' ) ; foreach ( $ contentTypes as $ contentType ) { $ normalised [ $ contentType [ 'tablename' ] ] = $ contentType ; } return $ normalised ; } | Return an array of ContentTypes with the table name is the key . |
43,227 | private function addContentTypeTableColumns ( ContentType $ tableObj , Table $ table , array $ fields , FieldManager $ fieldManager ) { foreach ( $ fields as $ fieldName => $ values ) { $ reservedList = $ this -> connection -> getDatabasePlatform ( ) -> getReservedKeywordsList ( ) ; if ( $ reservedList -> isKeyword ( $... | Add the custom columns for the ContentType . |
43,228 | private function addContentTypeTableColumn ( ContentType $ tableObj , Table $ table , $ fieldName , array $ values , FieldManager $ fieldManager ) { if ( $ tableObj -> isKnownType ( $ values [ 'type' ] ) ) { $ addIndex = isset ( $ values [ 'index' ] ) && ( bool ) $ values [ 'index' ] === true ; $ tableObj -> addCustomF... | Add a single column to the ContentType table . |
43,229 | private function getContentTypeTableColumnType ( array $ values ) { if ( isset ( $ values [ 'type' ] ) && $ values [ 'type' ] === 'select' && isset ( $ values [ 'multiple' ] ) && $ values [ 'multiple' ] === true ) { return 'selectmultiple' ; } return $ values [ 'type' ] ; } | Certain field types can have single or JSON array types figure it out . |
43,230 | public function execute ( ) { $ result = null ; foreach ( $ this as $ query ) { try { if ( $ result === null ) { $ result = $ query -> execute ( ) ; if ( $ query -> getType ( ) === 3 ) { $ this -> setLastInsertId ( $ query ) ; } foreach ( $ this -> resultCallbacks as $ callback ) { $ callback ( $ query , $ result , $ t... | Execute function iterate the queries and execute them sequentially . |
43,231 | public static function makeValuePairs ( $ array , $ key , $ value ) { Deprecated :: method ( 3.3 , 'Use array_column() or Arr::column() instead.' ) ; if ( ! is_array ( $ array ) ) { return [ ] ; } return self :: column ( $ array , $ value , $ key ) ; } | Make a simple array consisting of key = > value pairs that can be used in select - boxes in forms . |
43,232 | protected function getComposer ( ) { if ( ! $ this -> composer ) { putenv ( 'COMPOSER_HOME=' . $ this -> app [ 'path_resolver' ] -> resolve ( '%cache%/composer' ) ) ; chdir ( $ this -> getOptions ( ) -> baseDir ( ) ) ; try { $ this -> composer = Factory :: create ( $ this -> getIO ( ) , $ this -> getOptions ( ) -> comp... | Get a Composer object . |
43,233 | protected function getPreferedTarget ( $ option ) { $ prefer = [ 'source' => false , 'dist' => false , ] ; switch ( $ option ) { case 'source' : $ prefer [ 'source' ] = true ; break ; case 'dist' : $ prefer [ 'dist' ] = true ; break ; case 'auto' : default : break ; } return $ prefer ; } | Determine if we re to force installation from package sources when possible including VCS information . |
43,234 | private function setAllowSslDowngrade ( $ choice ) { $ repos = $ this -> getComposer ( ) -> getRepositoryManager ( ) -> getRepositories ( ) ; foreach ( $ repos as $ repo ) { if ( ! $ repo instanceof ComposerRepository ) { continue ; } $ reflection = new \ ReflectionClass ( $ repo ) ; $ allowSslDowngrade = $ reflection ... | Set repos to allow HTTP instead of HTTPS . |
43,235 | protected function getPool ( ) { if ( ! $ this -> pool ) { $ this -> pool = new Pool ( $ this -> getMinimumStability ( ) ) ; foreach ( $ this -> getRepos ( ) as $ repo ) { $ this -> pool -> addRepository ( $ repo ) ; } } return $ this -> pool ; } | Return a resolver pool that contains repositories that provide packages . |
43,236 | protected function getRepos ( ) { if ( ! $ this -> repos ) { $ this -> repos = $ this -> getComposer ( ) -> getRepositoryManager ( ) -> getRepositories ( ) ; } return $ this -> repos ; } | Get all our repos . |
43,237 | protected function doInitialize ( ) { $ this -> collection = new FieldCollection ( ) ; $ this -> collection -> setGrouping ( $ this -> grouping ) ; if ( $ this -> references ) { $ repo = $ this -> em -> getRepository ( FieldValue :: class ) ; $ instances = $ repo -> findBy ( [ 'id' => $ this -> references ] ) ; if ( $ ... | Handles the conversion of references to entities . |
43,238 | public function uploadNamespace ( Request $ request , $ namespace ) { if ( $ handler = $ request -> get ( 'handler' ) ) { if ( is_array ( $ handler ) ) { return $ this -> processCustomUploadHandler ( $ request , $ handler ) ; } list ( $ namespace , $ prefix ) = $ this -> parser ( $ handler ) ; $ this -> app [ 'upload.n... | Route to handle file uploads . |
43,239 | private function parser ( $ handler ) { $ parts = explode ( '://' , $ handler ) ; if ( count ( $ parts ) === 2 ) { $ namespace = $ parts [ 0 ] ; array_shift ( $ parts ) ; } else { $ namespace = $ this -> app [ 'upload.namespace' ] ; } $ prefix = rtrim ( $ parts [ 0 ] , '/' ) . '/' ; return [ $ namespace , $ prefix ] ; ... | Parse a string and determine the upload prefix and namespace . |
43,240 | private function handleUploadFiles ( Request $ request , $ namespace , $ files = null ) { $ filesToProcess = $ this -> getFilesToProcess ( $ request , $ namespace , $ files ) ; $ result = $ this -> app [ 'upload' ] -> process ( $ filesToProcess ) ; if ( $ result -> isValid ( ) ) { if ( ! $ this -> app [ 'config' ] -> g... | Perform a file upload . |
43,241 | private function getFilesToProcess ( Request $ request , $ namespace , $ files = null ) { $ this -> app [ 'upload.namespace' ] = $ namespace ; if ( $ files === null ) { $ files = $ request -> files -> get ( $ namespace ) ; } if ( ! $ files ) { return [ ] ; } $ filesToProcess = [ ] ; foreach ( $ files as $ file ) { if (... | Determine the list of files to upload . |
43,242 | private function processCustomUploadHandler ( Request $ request , array $ handler ) { list ( $ namespace , $ prefix ) = $ this -> parser ( $ handler [ 0 ] ) ; $ this -> app [ 'upload.namespace' ] = $ namespace ; $ this -> app [ 'upload.prefix' ] = $ prefix ; $ fullResult = $ this -> handleUploadFiles ( $ request , $ na... | This handles the more advanced functionality where multiple upload handlers are provided . Only the first one is returned as a result the result of this first upload is then attempted to copy to the remaining handlers . |
43,243 | protected function invokeCallable ( callable $ callback , $ callbackArguments ) { if ( $ callbackArguments === null ) { return $ callback ( ) ; } if ( Arr :: isIndexed ( $ callbackArguments ) ) { return call_user_func_array ( $ callback , ( array ) $ callbackArguments ) ; } $ orderedArgs = $ this -> getArguments ( $ ca... | Get the return value from the callable . |
43,244 | private function getArguments ( callable $ callback , array $ callbackArguments ) { $ parameters = $ this -> getParameters ( $ callback ) ; $ arguments = [ ] ; foreach ( $ parameters as $ param ) { if ( array_key_exists ( $ param -> getName ( ) , $ callbackArguments ) ) { $ arguments [ ] = $ callbackArguments [ $ param... | Get an ordered list of arguments . |
43,245 | private function getParameters ( callable $ callback ) { if ( is_array ( $ callback ) ) { $ mirror = new ReflectionMethod ( $ callback [ 0 ] , $ callback [ 1 ] ) ; } elseif ( is_object ( $ callback ) && ! $ callback instanceof \ Closure ) { $ mirror = new ReflectionObject ( $ callback ) ; $ mirror = $ mirror -> getMeth... | Get the callback function s parameters . |
43,246 | public function build ( MenuEntry $ root ) { $ this -> addConfiguration ( $ root ) ; $ this -> addFileManagement ( $ root ) ; $ this -> addExtend ( $ root ) ; return $ root ; } | Build the menus . |
43,247 | private function addFileManagement ( MenuEntry $ root ) { $ fileEntry = $ root -> add ( MenuEntry :: create ( 'files' ) -> setLabel ( Trans :: __ ( 'general.phrase.file-management' ) ) -> setIcon ( 'fa:cubes' ) -> setPermission ( 'files' ) ) ; $ fileEntry -> add ( MenuEntry :: create ( 'files_uploads' ) -> setRoute ( '... | File management menus . |
43,248 | private function addExtend ( MenuEntry $ root ) { $ root -> add ( MenuEntry :: create ( 'extensions' ) -> setRoute ( 'extensions' ) -> setLabel ( Trans :: __ ( 'general.phrase.extensions-overview' ) ) -> setIcon ( 'fa:cubes' ) -> setPermission ( 'extensions' ) ) ; $ root -> add ( MenuEntry :: create ( 'custom' ) -> set... | Extensions menus . |
43,249 | public function handleStorage ( $ fieldObject ) { $ type = $ fieldObject -> getStorageType ( ) ; $ typeName = $ type -> getName ( ) ; if ( $ typeName === 'json' ) { $ typeName = 'json_array' ; } $ typeCol = 'value_' . $ typeName ; $ this -> $ typeCol = $ this -> getValue ( ) ; } | When the entity needs to be persisted the value has to be copied to a field specific to the storage type . |
43,250 | public static function parse ( Composer $ composer , $ webPath , $ path , array $ jsonData ) { $ name = $ jsonData [ 'name' ] ; $ class = self :: parseClass ( $ jsonData ) ; $ constraint = self :: parseConstraint ( $ jsonData ) ; $ valid = self :: parseValid ( $ composer , $ class , $ constraint ) ; return new self ( $... | Create class from uncertain JSON data . |
43,251 | private static function parseValid ( Composer $ composer , $ class , $ constraint ) { if ( $ constraint === null ) { return false ; } $ provides = $ composer -> getPackage ( ) -> getProvides ( ) ; $ boltVersion = isset ( $ provides [ 'bolt/bolt' ] ) ? $ provides [ 'bolt/bolt' ] : new Link ( '__root__' , 'bolt/bolt' , n... | Check if the extension is valid for loading i . e has a class and is withing version constraints . |
43,252 | public function create ( $ params = [ ] , ClassMetadata $ metadata = null ) { $ params = new ArrayObject ( $ params ) ; $ builder = $ this -> getEntityBuilder ( ) ; $ entity = $ builder -> getEntity ( ) ; $ preEventArgs = new HydrationEvent ( $ params , [ 'entity' => $ entity , 'repository' => $ this ] ) ; $ this -> ev... | Creates a new empty entity and passes the supplied data to the constructor . |
43,253 | public function count ( ) { $ qb = $ this -> getLoadQuery ( ) -> select ( 'COUNT(' . $ this -> getAlias ( ) . '.id) as count' ) -> resetQueryParts ( [ 'groupBy' , 'join' ] ) ; $ result = $ qb -> execute ( ) -> fetchColumn ( 0 ) ; return ( int ) $ result ; } | Return the number of rows used in this repository table . |
43,254 | protected function findWithCriteria ( array $ criteria , array $ orderBy = null , $ limit = null , $ offset = null ) { $ qb = $ this -> getLoadQuery ( ) ; foreach ( $ criteria as $ col => $ val ) { if ( is_array ( $ val ) ) { $ qb -> andWhere ( $ this -> getAlias ( ) . ".$col IN(:$col)" ) ; $ qb -> setParameter ( ":$co... | Internal method to build a basic select returns QB object . |
43,255 | public function findWith ( QueryBuilder $ query ) { $ this -> load ( $ query ) ; $ result = $ query -> execute ( ) -> fetchAll ( ) ; if ( $ result ) { return $ this -> hydrateAll ( $ result , $ query ) ; } return [ ] ; } | Method to hydrate and return a QueryBuilder query . |
43,256 | public function findOneWith ( QueryBuilder $ query ) { $ this -> load ( $ query ) ; $ result = $ query -> execute ( ) -> fetch ( ) ; if ( $ result ) { return $ this -> hydrate ( $ result , $ query ) ; } return false ; } | Method to hydrate and return a single QueryBuilder result . |
43,257 | public function queryWith ( QueryInterface $ query ) { $ this -> query ( $ query ) ; $ queryBuilder = $ query -> build ( ) ; return $ this -> findWith ( $ queryBuilder ) ; } | Method to execute query from a Bolt QueryInterface object The query is passed to the pre - load handlers then built into a QueryBuilder instance that can be executed . |
43,258 | protected function load ( QueryBuilder $ query ) { $ metadata = $ this -> getClassMetadata ( ) ; foreach ( $ metadata -> getFieldMappings ( ) as $ field ) { $ fieldtype = $ this -> getFieldManager ( ) -> get ( $ field [ 'fieldtype' ] , $ field ) ; if ( $ fieldtype instanceof FieldTypeInterface ) { $ fieldtype -> load (... | Internal method to run load method on each field for the managed entity . |
43,259 | protected function query ( QueryInterface $ query ) { $ metadata = $ this -> getClassMetadata ( ) ; foreach ( $ metadata -> getFieldMappings ( ) as $ field ) { $ fieldtype = $ this -> getFieldManager ( ) -> get ( $ field [ 'fieldtype' ] , $ field ) ; if ( $ fieldtype instanceof FieldTypeInterface ) { $ fieldtype -> que... | Internal method to run query method on each field for the managed entity . |
43,260 | protected function persist ( QuerySet $ queries , $ entity , $ exclusions = [ ] ) { $ metadata = $ this -> getClassMetadata ( ) ; foreach ( $ metadata -> getFieldMappings ( ) as $ field ) { $ fieldName = $ field [ 'fieldname' ] ; if ( in_array ( $ fieldName , $ exclusions ) ) { continue ; } if ( ! isset ( $ entity -> $... | Internal method to run persist method on each field for the managed entity . |
43,261 | public function delete ( $ entity ) { $ event = new StorageEvent ( $ entity ) ; $ this -> event ( ) -> dispatch ( StorageEvents :: PRE_DELETE , $ event ) ; $ qb = $ this -> em -> createQueryBuilder ( ) -> delete ( $ this -> getTableName ( ) ) -> where ( 'id = :id' ) -> setParameter ( 'id' , $ entity -> getId ( ) ) ; $ ... | Deletes a single object . |
43,262 | public function save ( $ entity , $ silent = null ) { try { if ( $ existing = $ entity -> getId ( ) ) { $ creating = false ; } else { $ creating = true ; } } catch ( \ Exception $ e ) { $ creating = $ existing = false ; } if ( $ silent === null ) { $ event = new StorageEvent ( $ entity , [ 'create' => $ creating ] ) ; ... | Saves a single object . |
43,263 | public function insert ( $ entity ) { $ querySet = new QuerySet ( ) ; $ qb = $ this -> em -> createQueryBuilder ( ) ; $ qb -> insert ( $ this -> getTableName ( ) ) ; $ querySet -> append ( $ qb ) ; $ this -> persist ( $ querySet , $ entity , [ 'id' ] ) ; $ result = $ querySet -> execute ( ) ; try { $ entity -> setId ( ... | Saves a new object into the database . |
43,264 | public function update ( $ entity , $ exclusions = [ ] ) { $ querySet = new QuerySet ( ) ; $ querySet -> setParentId ( $ entity -> getId ( ) ) ; $ qb = $ this -> em -> createQueryBuilder ( ) ; $ qb -> update ( $ this -> getTableName ( ) ) -> where ( 'id = :id' ) -> setParameter ( 'id' , $ entity -> getId ( ) ) ; $ quer... | Updates an object into the database . |
43,265 | protected function hydrate ( array $ data , QueryBuilder $ qb ) { $ entity = $ this -> getEntityBuilder ( ) -> getEntity ( ) ; $ data = new ArrayObject ( $ data ) ; $ preEventArgs = new HydrationEvent ( $ data , [ 'entity' => $ entity , 'repository' => $ this ] ) ; $ this -> event ( ) -> dispatch ( StorageEvents :: PRE... | Internal method to hydrate an Entity Object from fetched data . |
43,266 | protected function hydrateAll ( array $ data , QueryBuilder $ qb ) { $ rows = [ ] ; foreach ( $ data as $ row ) { $ rows [ ] = $ this -> hydrate ( $ row , $ qb ) ; } return $ rows ; } | Internal method to hydrate an array of Entity Objects from fetched data . |
43,267 | public function widget ( Request $ request , $ key ) { if ( ! $ widget = $ this -> app [ 'asset.queue.widget' ] -> get ( $ key ) ) { return $ this -> abort ( Response :: HTTP_NOT_FOUND ) ; } $ authCookie = $ request -> cookies -> get ( $ this -> app [ 'token.authentication.name' ] ) ; if ( $ widget -> getZone ( ) !== '... | Render a widget and return the HTML so it can be inserted in the page . |
43,268 | private function generateNamesDescription ( ) { foreach ( $ this -> app [ 'config' ] -> get ( 'contenttypes' ) as $ ctname => $ ctype ) { $ keyprefix = 'contenttypes.' . $ this -> slugifyKey ( $ ctname ) . '.' ; $ setkeys = [ 'name.plural' => 'name' , 'name.singular' => 'singular_name' , 'description' => 'description' ... | Generates keys for contenttypes names and description and save found names for later usage . |
43,269 | private function generateGroups ( ) { foreach ( $ this -> app [ 'config' ] -> get ( 'contenttypes' ) as $ ctname => $ ctype ) { $ keyprefix = 'contenttypes.' . $ this -> slugifyKey ( $ ctname ) . '.group.' ; if ( isset ( $ ctype [ 'groups' ] ) && is_array ( $ ctype [ 'groups' ] ) ) { foreach ( $ ctype [ 'groups' ] as $... | Generates keys for tab group names . |
43,270 | private function generateFromGeneric ( ) { $ ctypes = $ this -> app [ 'config' ] -> get ( 'contenttypes' ) ; $ translatables = array_filter ( array_keys ( $ this -> translatables ) , function ( $ key ) { return substr ( $ key , 0 , 21 ) === 'contenttypes.generic.' && substr ( $ key , 21 , 6 ) !== 'group.' ; } ) ; forea... | Generates strings for contenttypes from generic translations . |
43,271 | private function audit ( $ msg ) { if ( $ this -> app [ 'config' ] -> get ( 'general/debug_permission_audit_mode' , false ) ) { $ this -> app [ 'logger.system' ] -> info ( $ msg , [ 'event' => 'authentication' ] ) ; } } | Write an entry to the permission audit log . |
43,272 | public function getRole ( $ roleName ) { switch ( $ roleName ) { case self :: ROLE_ANONYMOUS : return [ 'label' => Trans :: __ ( 'permissions.roles.label.anonymous' ) , 'description' => Trans :: __ ( 'permissions.roles.description.anonymous' ) , 'builtin' => true , ] ; case self :: ROLE_EVERYONE : return [ 'label' => T... | Gets meta - information on the specified role . |
43,273 | public function getUserRoles ( $ user , Content $ content = null ) { $ userRoleNames = $ user [ 'roles' ] ; if ( ! is_array ( $ userRoleNames ) ) { throw new AccessControlException ( 'Expected a user-like array, but the "roles" property is not an array' ) ; } $ userRoleNames [ ] = self :: ROLE_EVERYONE ; if ( $ content... | Gets the roles for a given user . If a content type is specified the owner role is added if appropriate . |
43,274 | public function getManipulatableRoles ( array $ currentUser ) { $ manipulatableRoles = [ ] ; foreach ( $ this -> getDefinedRoles ( ) as $ roleName => $ role ) { if ( $ this -> checkPermission ( $ currentUser [ 'roles' ] , 'manipulate' , 'roles-hierarchy' , $ roleName ) ) { $ manipulatableRoles [ ] = $ roleName ; } } re... | Gets the roles the current user can manipulate . |
43,275 | public function checkPermission ( $ roleNames , $ permissionName , $ type = null , $ item = null ) { if ( $ type !== null && $ item === null ) { $ item = $ type ; $ type = 'contenttype' ; } if ( is_array ( $ item ) && isset ( $ item [ 'username' ] ) ) { $ itemStr = sprintf ( ' for user <tt>%s</tt>' , $ item [ 'username... | Low - level permission check . Given a set of available roles a permission and an optional content type this method checks whether the permission may be granted . |
43,276 | private function checkRoleGlobalPermission ( $ roleName , $ permissionName ) { $ roles = $ this -> getRolesByGlobalPermission ( $ permissionName ) ; if ( ! is_array ( $ roles ) ) { if ( $ roleName !== self :: ROLE_ROOT ) { $ this -> app [ 'logger.system' ] -> warn ( "Configuration error: Permission '$permissionName' is... | Check if a given role has the specified permission . |
43,277 | private function checkRoleHierarchyPermission ( $ roleName , $ permissionName , $ role ) { if ( is_string ( $ role ) ) { $ permissions = $ this -> app [ 'config' ] -> get ( "permissions/roles-hierarchy/$permissionName/$role" , [ ] ) ; return in_array ( $ roleName , $ permissions ) ; } $ user = $ role ; foreach ( $ user... | Check if a hierarchy role has a sub - role . |
43,278 | private function checkRoleContentTypePermission ( $ roleName , $ permissionName , $ contenttype ) { if ( ! $ this -> app [ 'storage.metadata' ] -> createContentType ( $ contenttype ) ) { return false ; } $ roles = $ this -> getRolesByContentTypePermission ( $ permissionName , $ contenttype ) ; return in_array ( $ roleN... | Check if a role has a specific Contenttype permission . |
43,279 | public function getContentTypeUserPermissions ( $ contentTypeSlug , $ user ) { $ permissions = [ ] ; foreach ( array_keys ( $ this -> contentTypePermissions ) as $ contentTypePermission ) { $ permissions [ $ contentTypePermission ] = $ this -> isAllowed ( $ contentTypePermission , $ user , $ contentTypeSlug ) ; } retur... | Return a list of ContentType permissions that a user has for the ContentType . |
43,280 | public function getRolesByContentTypePermission ( $ permissionName , $ contenttype ) { $ overrideRoles = $ this -> app [ 'config' ] -> get ( "permissions/contenttype-all/$permissionName" ) ; if ( ! is_array ( $ overrideRoles ) ) { $ overrideRoles = [ ] ; } $ contenttypeRoles = $ this -> app [ 'config' ] -> get ( "permi... | Lists the roles that would grant the specified permission for the specified content type . Sort of a reverse lookup on the permission check . |
43,281 | public function getEffectiveRolesForUser ( $ user ) { if ( isset ( $ user [ 'roles' ] ) && is_array ( $ user [ 'roles' ] ) ) { $ userRoles = $ user [ 'roles' ] ; $ userRoles [ ] = self :: ROLE_EVERYONE ; } else { $ userRoles = [ ] ; } $ userRoles [ ] = self :: ROLE_ANONYMOUS ; return $ userRoles ; } | Gets the effective roles for a given user . The effective roles include the roles that were explicitly assigned as well as the built - in automatic roles . |
43,282 | private function isAllowedRule ( $ rule , $ user , $ userRoles , $ content , $ contenttypeSlug , $ contentid ) { switch ( $ rule [ 'type' ] ) { case PermissionParser :: P_TRUE : return true ; case PermissionParser :: P_FALSE : return false ; case PermissionParser :: P_SIMPLE : return $ this -> isAllowedSingle ( $ rule ... | Check if a user is allowed a rule type . |
43,283 | private function isAllowedSingle ( $ what , $ user , $ userRoles , $ content = null , $ contenttypeSlug = null , $ contentId = null ) { if ( $ content !== null ) { $ parts = [ 'contenttype' , $ contenttypeSlug , $ what , $ contentId , ] ; } else { $ parts = explode ( ':' , $ what ) ; } switch ( $ parts [ 0 ] ) { case '... | Check if a user has a specific role . |
43,284 | public function isContentStatusTransitionAllowed ( $ fromStatus , $ toStatus , $ user , $ contenttype , $ contentid = null ) { $ perm = $ this -> getContentStatusTransitionPermission ( $ fromStatus , $ toStatus ) ; if ( $ perm === null ) { return true ; } return $ this -> isAllowed ( $ perm , $ user , $ contenttype , $... | Check to see if a user is allowed to change that status of a Contenttype record to a target status . |
43,285 | public function getUserId ( $ who ) { $ user = $ this -> users -> getUser ( $ who ) ; if ( isset ( $ user [ 'id' ] ) ) { return $ user [ 'id' ] ; } return false ; } | Get an id number for a user based on the given name . Returns an integer id on success and false otherwise . |
43,286 | public function build ( array $ contentTypeNames , $ count , $ canExceedMax = false ) { $ response = MutableBag :: fromRecursive ( [ 'created' => [ ] , 'errors' => [ ] , 'warnings' => [ ] ] ) ; foreach ( $ contentTypeNames as $ contentTypeName ) { try { $ existingCount = $ this -> storage -> getRepository ( $ contentTy... | Build up - to n number of pre - filled ContentType records . |
43,287 | public function changeRecord ( Request $ request , $ contenttype , $ contentid , $ id ) { $ entry = $ this -> changeLogRepository ( ) -> getChangeLogEntry ( $ contenttype , $ contentid , $ id , '=' ) ; if ( empty ( $ entry ) ) { $ error = Trans :: __ ( 'logs.change-log.not-found' ) ; $ this -> abort ( Response :: HTTP_... | Show a single change log entry . |
43,288 | public function changeRecordListing ( Request $ request , $ contenttype , $ contentid ) { $ page = $ request -> get ( 'page' ) ; $ pagination = $ this -> getPagination ( $ page ) ; $ queryOptions = $ this -> getQueryOptions ( $ pagination ) ; if ( empty ( $ contenttype ) ) { $ data = [ 'title' => Trans :: __ ( 'logs.ch... | Show a list of changelog entries . |
43,289 | public function systemOverview ( Request $ request ) { $ action = $ request -> query -> get ( 'action' ) ; if ( $ action == 'clear' ) { $ this -> manager ( ) -> clear ( 'system' ) ; $ this -> flashes ( ) -> success ( Trans :: __ ( 'logs.system-log.cleared' ) ) ; return $ this -> redirectToRoute ( 'systemlog' ) ; } else... | System log overview route . |
43,290 | private function getPagination ( $ page ) { $ limit = 5 ; if ( $ page !== null ) { if ( $ page === 'all' ) { $ limit = null ; $ page = null ; } else { $ page = ( int ) $ page ; } } else { $ page = 1 ; } return [ 'page' => $ page , 'limit' => $ limit ] ; } | Calculate pagination parameters . |
43,291 | private function getQueryOptions ( $ pagination ) { $ options = [ 'order' => 'date' , 'direction' => 'DESC' , ] ; if ( $ pagination [ 'limit' ] ) { $ options [ 'limit' ] = $ pagination [ 'limit' ] ; } if ( $ pagination [ 'page' ] > 0 && $ pagination [ 'limit' ] ) { $ options [ 'offset' ] = ( $ pagination [ 'page' ] - 1... | Calculate the query options . |
43,292 | public function getDirectories ( $ showHidden = false ) { $ it = $ this -> getContents ( ) ; return array_filter ( $ it , function ( HandlerInterface $ handler ) use ( $ showHidden ) { return $ handler -> isDir ( ) && ( $ showHidden ? : strpos ( $ handler -> getFilename ( ) , '.' ) !== 0 ) ; } ) ; } | Return the directories content listing of the requested target . |
43,293 | public function getFiles ( $ showHidden = false ) { $ it = $ this -> getContents ( ) ; return array_filter ( $ it , function ( HandlerInterface $ handler ) use ( $ showHidden ) { return $ handler -> isFile ( ) && ( $ showHidden ? : strpos ( $ handler -> getFilename ( ) , '.' ) !== 0 ) ; } ) ; } | Return the files content listing of the requested target . |
43,294 | private function getContents ( ) { if ( $ this -> contents ) { return $ this -> contents ; } return $ this -> contents = $ this -> directory -> getContents ( ) ; } | Lazy load & cache the directory contents . |
43,295 | public function getContentType ( ) { $ contentType = $ this -> getSubject ( ) -> contenttype ; if ( $ contentType !== null && isset ( $ contentType [ 'slug' ] ) ) { return $ contentType [ 'slug' ] ; } return null ; } | Return the record s ContentType name . |
43,296 | public function handle ( $ path ) { try { $ this -> filesystem -> url ( $ path ) ; } catch ( \ Exception $ e ) { return false ; } return true ; } | Determine if the path has a url . |
43,297 | public function ping ( $ addQuery = false , $ debugClient = false ) { try { $ this -> doPing ( $ addQuery , $ debugClient ) ; return true ; } catch ( ClientException $ e ) { $ this -> messages [ ] = Trans :: __ ( 'page.extend.error-message-client' , [ '%errormessage%' => $ e -> getMessage ( ) ] ) ; } catch ( ServerExce... | Ping site to see if we have a valid connection and it is responding correctly . |
43,298 | public function getOriginal ( $ entity ) { $ entities = $ this -> flatten ( ) ; foreach ( $ entities as $ existing ) { if ( $ existing -> getName ( ) == $ entity -> getName ( ) && $ existing -> getGrouping ( ) == $ entity -> getGrouping ( ) && $ existing -> getFieldname ( ) == $ entity -> getFieldname ( ) && ( ! $ exis... | This loops over the existing collection to see if the properties in the incoming are already available on a saved record . |
43,299 | public function action ( $ contentTypeSlug , ListingOptions $ options ) { $ contentType = $ this -> em -> getContentType ( $ contentTypeSlug ) ; $ contentParameters = [ 'paging' => true , 'hydrate' => true , 'order' => $ options -> getOrder ( ) ? : $ contentType [ 'sort' ] , 'page' => $ options -> getPage ( ) , 'filter... | Fetch a listing of ContentType records . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.