idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
7,700 | private function findSibling ( Collection $ elements , SortableInterface $ current , $ next = false ) { if ( $ next ) { $ sibling = $ elements -> filter ( function ( SortableInterface $ s ) use ( $ current ) { return $ s -> getPosition ( ) > $ current -> getPosition ( ) ; } ) -> first ( ) ; } else { $ sibling = $ eleme... | Finds the previous element based on position . |
7,701 | static public function addClass ( \ DOMElement $ element , $ classes ) { if ( ! is_array ( $ classes ) ) { $ classes = [ $ classes ] ; } $ c = explode ( ' ' , ( string ) $ element -> getAttribute ( 'class' ) ) ; foreach ( $ classes as $ n ) { if ( empty ( $ n ) ) { continue ; } if ( ! in_array ( $ n , $ c , true ) ) { ... | Adds the class to the dom element . |
7,702 | static public function addStyle ( \ DOMElement $ element , $ property , $ value ) { $ s = static :: explodeStyles ( ( string ) $ element -> getAttribute ( 'style' ) ) ; $ s [ $ property ] = $ value ; $ element -> setAttribute ( 'style' , static :: implodeStyles ( $ s ) ) ; } | Adds the style to the dom element . |
7,703 | static public function explodeStyles ( $ styles ) { $ a = [ ] ; $ s = explode ( ';' , $ styles ) ; foreach ( $ s as $ c ) { if ( empty ( $ c ) ) continue ; list ( $ p , $ v ) = explode ( ':' , $ c ) ; $ a [ $ p ] = $ v ; } return $ a ; } | Explodes the style attribute . |
7,704 | static public function implodeStyles ( array $ styles ) { $ a = [ ] ; foreach ( $ styles as $ p => $ v ) { $ a [ ] = "$p:$v" ; } return implode ( ';' , $ a ) ; } | Implodes the style attribute . |
7,705 | public function to ( $ url , $ locale = null , $ parameters = [ ] , $ secure = null ) { if ( is_bool ( $ secure ) ) { $ this -> urlparser -> secure ( $ secure ) ; } elseif ( $ this -> forceSecure ) { $ this -> urlparser -> secure ( ) ; } return $ this -> urlparser -> set ( $ url ) -> localize ( $ this -> scope -> segme... | Generate a localized url . |
7,706 | public static function exists ( $ app = 'global' , $ key ) { return ( ( new static ( ) ) -> where ( 'app' , $ app ) -> where ( 'key' , $ key ) -> where ( 'value' , true ) -> count ( ) ? true : false ) ; } | Checks if a permission exists . |
7,707 | public static function createGlobalPermissions ( $ globalPermissions , $ id ) { $ query = [ ] ; if ( $ globalPermissions ) { foreach ( $ globalPermissions as $ globalPermissionKey => $ globalPermissionValue ) { if ( $ globalPermissionValue ) { $ query [ ] = array ( 'groupID' => $ id , 'app' => 'global' , 'key' => $ glo... | Prepare global permission array to be stored on database . Gets input from the front - end and customizes object to be stored as JSON in DB . |
7,708 | public static function createPermissions ( $ permissions , $ id ) { $ query = [ ] ; if ( $ permissions ) { foreach ( $ permissions as $ appName => $ app ) { foreach ( $ app as $ permissionType => $ permission ) { if ( $ permissionType == 'defaultPermissionsValues' ) { foreach ( $ permission as $ key ) { $ query [ ] = a... | Prepare custom and default permission array to be stored on database . Gets input from the front - end and customizes object to be stored as JSON in DB . |
7,709 | private function checkScope ( Entity & $ object ) { if ( ! empty ( $ this -> localization ) && ! empty ( $ this -> block ) ) { try { $ this -> localization -> matchDiscriminator ( $ this -> block ) ; } catch ( \ Exception $ e ) { $ object = null ; throw $ e ; } } } | Checks if associations scopes are matching |
7,710 | public function finish ( array $ items = [ ] ) : bool { $ changed = false ; foreach ( $ items as $ key => $ value ) { $ serialized = \ serialize ( $ value ) ; if ( ! $ this -> check ( $ key , $ serialized ) ) { $ changed = true ; try { $ this -> saving ( $ key , $ serialized , $ this -> isNewKey ( $ key ) ) ; } catch (... | Save data to database . |
7,711 | protected function saving ( string $ key , $ value , bool $ isNew ) : void { if ( $ value === 'N;' ) { $ this -> delete ( $ key ) ; } else { $ this -> save ( $ key , $ value , $ isNew ) ; } } | Attempt to save or remove data to the database . |
7,712 | protected function asArray ( $ data = [ ] ) : array { if ( $ data instanceof Collection ) { $ data = $ data -> all ( ) ; } elseif ( $ data instanceof Arrayable ) { $ data = $ data -> toArray ( ) ; } return $ data ; } | Convert mixed value fetch from database to array . |
7,713 | public function getLocale ( ) { if ( $ this -> locale === null ) $ this -> locale = $ this -> getDefinition ( ) -> getEntityManager ( ) -> getDefaultLocale ( ) ; return $ this -> locale ; } | Return the default locale . |
7,714 | public function loadDefault ( ) { foreach ( $ this -> getDefinition ( ) -> properties ( ) as $ name => $ property ) $ this -> _set ( $ name , $ property -> getDefault ( $ this , $ name ) , null , false ) ; return $ this ; } | Load default data . |
7,715 | public function getValidator ( array $ locales = [ ] ) { $ validator = $ this -> getDefinition ( ) -> getEntityManager ( ) -> createValidator ( ) ; return $ this -> prepareValidator ( $ validator , $ locales ) ; } | Get a validator . |
7,716 | public function errors ( $ groups = [ ] ) { $ data = $ this -> toArrayRaw ( ) ; $ validator = $ this -> getValidator ( ) ; $ report = $ this -> getDefinition ( ) -> trigger ( 'validation' , [ $ this , $ validator , $ groups , & $ data ] , function ( $ chain , $ entity , $ validator , $ groups , & $ data ) { $ report = ... | Return entity errors . |
7,717 | public function _get ( $ name , $ locale = null ) { $ name = strtolower ( $ name ) ; if ( ! $ locale ) $ locale = $ this -> getLocale ( ) ; if ( $ this -> getDefinition ( ) -> hasProperty ( $ name ) ) { if ( $ this -> getDefinition ( ) -> property ( $ name ) -> get ( 'i18n' ) && $ locale !== $ this -> getLocale ( ) ) {... | Hard get data . With no pre - processing . |
7,718 | public function get ( $ name , $ locale = null , $ hook = true ) { if ( ! $ locale ) $ locale = $ this -> getLocale ( ) ; if ( $ hook && ( $ res = $ this -> getDefinition ( ) -> trigger ( 'get' , [ $ this , $ name , $ locale ] ) ) !== null ) return $ res ; return $ this -> _get ( $ name , $ locale ) ; } | Hard get data . With pre - processing . |
7,719 | public function translate ( $ locale ) { $ localeEntity = clone $ this ; $ localeEntity -> setLocale ( $ locale ) ; if ( isset ( $ this -> data [ 'translations' ] [ $ locale ] ) ) $ localeEntity -> _set ( $ this -> data [ 'translations' ] [ $ locale ] ) ; unset ( $ localeEntity -> data [ 'translations' ] [ $ locale ] )... | Return entity in another language . |
7,720 | public function validI18N ( array $ locales = [ ] , $ groups = [ ] ) { if ( ! $ locales ) $ locales = $ this -> getLocales ( ) ; $ data = $ this -> toArrayRawI18N ( $ locales ) ; $ validator = $ this -> getValidator ( $ locales ) ; return $ validator -> valid ( $ data , $ groups ) ; } | Check if entity and translations are valid . |
7,721 | public function errorsI18N ( array $ locales = [ ] , $ groups = [ ] ) { if ( ! $ locales ) $ locales = $ this -> getLocales ( ) ; $ data = $ this -> toArrayRawI18N ( $ locales ) ; $ validator = $ this -> getValidator ( $ locales ) ; return $ validator -> errors ( $ data , $ groups ) ; } | Return errors for entity and translations . |
7,722 | public function getchangedI18N ( $ locale = null ) { if ( ! $ locale ) return array_keys ( $ this -> translationschanged ) ; elseif ( isset ( $ this -> translationschanged [ $ locale ] ) ) return array_keys ( $ this -> translationschanged [ $ locale ] ) ; else return [ ] ; } | Get the changed i18n properties . |
7,723 | public function write ( $ string ) { $ encodedLine = quoted_printable_encode ( $ this -> lastLine ) ; $ lineAndString = rtrim ( quoted_printable_encode ( $ this -> lastLine . $ string ) , "\r\n" ) ; $ write = substr ( $ lineAndString , strlen ( $ encodedLine ) ) ; $ this -> stream -> write ( $ write ) ; $ written = str... | Writes the passed string to the underlying stream after encoding it as quoted - printable . |
7,724 | private function beforeClose ( ) { if ( $ this -> isWritable ( ) && $ this -> lastLine !== '' ) { $ this -> stream -> write ( "\r\n" ) ; $ this -> lastLine = '' ; } } | Writes out a final CRLF if the current line isn t empty . |
7,725 | protected function render ( ) { $ prop = $ this -> props ; $ assets = $ this -> context -> getAssetsService ( ) ; if ( exists ( $ prop -> var ) ) $ assets -> addInlineScript ( sprintf ( 'var %s=%s;' , $ prop -> var , javascriptLiteral ( $ prop -> export , false ) ) ) ; elseif ( exists ( $ prop -> src ) ) $ assets -> ad... | Registers a script on the Page . |
7,726 | public function onResolveSubject ( SubjectEvent $ event ) { $ params = $ event -> getParameters ( ) ; if ( array_key_exists ( 'type' , $ params ) ) { if ( $ params [ 'type' ] == 'page' ) { $ event -> setSubject ( $ this -> createPageSubject ( ) ) ; $ event -> stopPropagation ( ) ; } elseif ( $ params [ 'type' ] == 'glo... | Resolve subject event handler . |
7,727 | private function createPageSubject ( ) { if ( null !== $ page = $ this -> pageHelper -> getCurrent ( ) ) { return $ this -> createSubjectFromPage ( $ page ) ; } return null ; } | Creates the current page social share subject . |
7,728 | private function createGlobalSubject ( ) { if ( null !== $ home = $ this -> pageHelper -> getHomePage ( ) ) { return $ this -> createSubjectFromPage ( $ home ) ; } return null ; } | Creates the global social share subject . |
7,729 | private function createSubjectFromPage ( PageInterface $ page ) { try { $ url = $ this -> urlGenerator -> generate ( $ page -> getRoute ( ) , [ ] , UrlGeneratorInterface :: ABSOLUTE_URL ) ; $ subject = new Subject ( ) ; $ subject -> title = $ page -> getSeo ( ) -> getTitle ( ) ; $ subject -> url = $ url ; return $ subj... | Creates the social share subject from the given page . |
7,730 | public function sendAction ( ) { $ contactForm = $ this -> createForm ( FrontForm :: CONTACT ) ; try { $ form = $ this -> validateForm ( $ contactForm ) ; $ event = new ContactEvent ( $ form ) ; $ this -> dispatch ( TheliaEvents :: CONTACT_SUBMIT , $ event ) ; $ this -> getMailer ( ) -> sendSimpleEmailMessage ( [ Confi... | send contact message |
7,731 | public function setHelpers ( $ helpers ) { if ( $ helpers instanceof HelpersInterface ) { $ helpers = $ helpers -> toArray ( ) ; } if ( ! is_array ( $ helpers ) && ! $ helpers instanceof Traversable ) { throw new InvalidArgumentException ( sprintf ( 'setHelpers expects an array of helpers, received %s' , ( is_object ( ... | Set the engine s helpers . |
7,732 | public function addHelper ( $ name , $ helper ) { if ( $ this -> mustache !== null ) { throw new RuntimeException ( 'Can not add helper to Mustache engine: the engine has already been initialized.' ) ; } $ this -> helpers [ $ name ] = $ helper ; return $ this ; } | Add a helper . |
7,733 | public static function altrim ( $ str , $ arr ) { try { foreach ( $ arr as & $ item ) { if ( is_string ( $ item ) ) { $ str = preg_replace ( "/^{$item}/" , '' , $ str ) ; } } return $ str ; } catch ( \ Exception $ e ) { } } | guplv mult string |
7,734 | public function findByTimetableAndDomId ( $ timetableId , $ domId ) { $ block = $ this -> findOneBy ( array ( 'timetable' => $ timetableId , 'domId' => $ domId , ) ) ; if ( empty ( $ block ) ) { $ block = new Block ( ) ; $ block -> setDomId ( $ domId ) ; $ timetable = $ this -> getEntityManager ( ) -> getRepository ( '... | find a block by Route Id And DomId |
7,735 | public function findByTimetableAndStopPointAndDomId ( $ timetableId , $ externalStopPointId , $ domId ) { $ query = $ this -> getEntityManager ( ) -> createQuery ( 'SELECT block FROM CanalTPMttBundle:Block block INNER JOIN block.stopPoint stop_point WHERE stop_point.externalId = :externalS... | find a block By StopPoint Navitia Id And DomId |
7,736 | public function execute ( PageRequest $ pageRequest ) { $ this -> pageRequest = $ pageRequest ; $ this -> pageResponse = $ this -> createPageResponse ( ) ; $ localization = $ pageRequest -> getLocalization ( ) ; if ( ! $ localization instanceof Localization ) { throw new \ UnexpectedValueException ( sprintf ( 'Expectin... | Main execute action . |
7,737 | protected function findBlockCache ( ) { if ( ! $ this -> pageRequest instanceof PageRequestView ) { return ; } $ localization = $ this -> pageRequest -> getLocalization ( ) ; $ blockCacheRequests = & $ this -> blockCacheRequests ; $ self = $ this ; $ this -> iterateBlocks ( function ( Block $ block ) use ( $ self , $ l... | Searches for block response cache . |
7,738 | protected function findBlockControllers ( ) { $ blockContentCache = & $ this -> blockContentCache ; $ blockCollection = $ this -> getBlockCollection ( ) ; $ this -> iterateBlocks ( function ( Block $ block , & $ blockController ) use ( $ blockCollection , & $ blockContentCache ) { $ blockId = $ block -> getId ( ) ; if ... | Create block controllers |
7,739 | protected function prepareBlockControllers ( ) { $ pageRequest = $ this -> pageRequest ; $ this -> iterateBlocks ( function ( Block $ block , BlockController $ blockController ) use ( $ pageRequest ) { $ blockController -> prepare ( $ pageRequest ) ; } ) ; } | Prepare block controllers |
7,740 | protected function findContextDependentBlockCache ( ) { if ( ! $ this -> pageRequest instanceof PageRequestView ) { return ; } $ localization = $ this -> pageRequest -> getLocalization ( ) ; $ context = $ this -> pageResponse -> getContext ( ) ; $ self = $ this ; $ this -> iterateBlocks ( function ( Block $ block ) use... | Late cache check for blocks which cache key depends on response context values . |
7,741 | protected function executeBlockControllers ( ) { $ blockContentCache = $ this -> blockContentCache ; $ this -> iterateBlocks ( function ( Block $ block , BlockController $ controller ) use ( & $ blockContentCache ) { if ( ! array_key_exists ( $ block -> getId ( ) , $ blockContentCache ) ) { $ controller -> execute ( ) ... | Executes block controllers |
7,742 | protected function cacheBlockResponses ( ) { $ cacheRequests = $ this -> blockCacheRequests ; $ localization = $ this -> pageRequest -> getLocalization ( ) ; $ logger = $ this -> container -> getLogger ( ) ; $ cache = $ this -> container -> getCache ( ) ; $ this -> iterateBlocks ( function ( Block $ block , BlockContro... | Caches block responses |
7,743 | private function iterateBlocks ( \ Closure $ function ) { $ return = array ( ) ; foreach ( $ this -> pageRequest -> getBlockSet ( ) as $ index => $ block ) { $ blockId = $ block -> getId ( ) ; if ( ! isset ( $ this -> blockControllers [ $ blockId ] ) ) { $ this -> blockControllers [ $ blockId ] = null ; } $ blockContro... | Iteration function for specific array of blocks . |
7,744 | protected function createPlaceResponse ( PlaceHolder $ placeHolder ) { return $ this -> pageRequest instanceof PageRequestEdit ? new PlaceHolderResponseEdit ( $ placeHolder ) : new PlaceHolderResponseView ( $ placeHolder ) ; } | Creates place holder response object . |
7,745 | protected static function decodeEntity ( $ match ) { $ match = preg_replace ( '|\&([a-z\_0-9\-]+)\=([a-z\_0-9\-/]+)|i' , self :: token . '\\1=\\2' , $ match [ 0 ] ) ; $ charset = 'UTF-8' ; if ( function_exists ( 'config' ) ) { $ charset = config ( ) -> getItem ( 'charset' ) ; } return str_replace ( self :: token , '&' ... | HTML Entity Decode Callback |
7,746 | public function import ( $ src ) { if ( ! file_exists ( realpath ( $ src ) ) ) throw new \ Exception ( 'File ' . $ src . ' does not exist.' ) ; $ host = $ this -> config [ 'host' ] ; $ user = $ this -> config [ 'user' ] ; $ pwd = $ this -> config [ 'password' ] ; $ db = $ this -> config [ 'database' ] ; $ cmd = 'mysql ... | Import an SQL file . |
7,747 | public function dump ( $ dst ) { $ host = $ this -> config [ 'host' ] ; $ user = $ this -> config [ 'user' ] ; $ pwd = $ this -> config [ 'password' ] ; $ db = $ this -> config [ 'database' ] ; \ Asgard \ File \ FileSystem :: mkdir ( dirname ( $ dst ) ) ; $ cmd = 'mysqldump --user=' . $ user . ' --password=' . $ pwd . ... | Dump an SQL file . |
7,748 | protected function _callListenersWithCallback ( $ listeners , array $ arguments , $ continueCallback ) { $ counter = count ( $ listeners ) ; $ execCount = 0 ; foreach ( $ listeners as $ listener ) { $ counter -- ; if ( $ result = $ this -> _callListener ( $ listener , $ arguments ) ) { return $ result ; } $ execCount +... | Call list of listeners with continue callback function |
7,749 | protected function _isContainPart ( $ eNameParts , $ ePaths ) { if ( count ( $ eNameParts ) !== count ( $ ePaths ) ) { return false ; } $ isFound = true ; foreach ( $ eNameParts as $ pos => $ eNamePart ) { if ( '*' !== $ eNamePart && array_key_exists ( $ pos , $ ePaths ) && $ ePaths [ $ pos ] !== $ eNamePart ) { $ isFo... | Check is one part name contain another one |
7,750 | public function cleanEventName ( $ eventName ) { $ eventName = strtolower ( $ eventName ) ; $ eventName = str_replace ( '..' , '.' , $ eventName ) ; $ eventName = trim ( $ eventName , '.' ) ; $ eventName = trim ( $ eventName ) ; if ( ! $ eventName ) { throw new Exception ( 'Event name is empty!' ) ; } return $ eventNam... | Prepare event namebefore using |
7,751 | public function fetch ( $ id , $ default = false ) { $ res = $ this -> driver -> fetch ( $ id ) ; if ( $ res === false ) { if ( $ default === false ) return false ; if ( is_callable ( $ default ) ) $ res = $ default ( ) ; else $ res = $ default ; $ this -> save ( $ id , $ res ) ; } return $ res ; } | Fetch a value . |
7,752 | public function save ( $ id , $ data , $ lifeTime = 0 ) { return $ this -> driver -> save ( $ id , $ data , $ lifeTime ) ; } | Save a key - value . |
7,753 | public function offsetSet ( $ offset , $ value ) { if ( is_null ( $ offset ) ) throw new \ LogicException ( 'Offset cannot be empty.' ) ; else $ this -> save ( $ offset , $ value ) ; } | Array set method |
7,754 | public function findImageSize ( $ sizeName ) { if ( $ this -> imageSizes -> containsKey ( $ sizeName ) ) { return $ this -> imageSizes -> get ( $ sizeName ) ; } else { return null ; } } | Find image size data |
7,755 | public function getImageSize ( $ sizeName ) { $ size = $ this -> findImageSize ( $ sizeName ) ; if ( ! $ size instanceof ImageSize ) { $ size = new ImageSize ( $ sizeName ) ; $ size -> setMaster ( $ this ) ; } return $ size ; } | Find image size data or create new if not found |
7,756 | protected function register_rewrite_rules ( ) { if ( ! empty ( $ this -> rewrite_rule ) ) { foreach ( $ this -> rewrite_rule as $ value ) { \ add_rewrite_rule ( $ value [ 'regex' ] , $ value [ 'replace' ] , $ value [ 'type' ] ) ; } } } | Registers Rewrite Rules With WordPress . |
7,757 | protected function register_rewrite_tags ( ) { if ( ! empty ( $ this -> rewrite_tag ) ) { foreach ( $ this -> rewrite_tag as $ param => $ value ) { \ add_rewrite_tag ( $ param , $ value ) ; } } } | Registers Rewrite Tag With WordPress . |
7,758 | protected function register_rewrite_endpoints ( ) { if ( ! empty ( $ this -> rewrite_endpoint ) ) { foreach ( $ this -> rewrite_endpoint as $ slug => $ arr ) { \ add_rewrite_endpoint ( $ slug , $ arr [ 'type' ] ) ; } } } | Registers Rewrite Endpoints With WordPress . |
7,759 | public function add_endpoint ( $ endpoint = '' , $ endpoint_type = \ EP_ROOT , $ callback = array ( ) ) { if ( ! isset ( $ this -> rewrite_endpoint [ $ endpoint ] ) ) { $ this -> rewrite_endpoint [ $ endpoint ] = array ( 'type' => $ endpoint_type , 'callback' => $ callback , ) ; } return $ this ; } | Adds Custom Endpoints To Endpoints Array . |
7,760 | public function add_rewrite_rule ( $ path = '' , $ after = 'top' ) { $ uri = '^' . preg_replace ( $ this -> parameter_pattern , $ this -> value_pattern_replace , $ path ) ; $ url = 'index.php?' ; $ _url = array ( ) ; $ matches = [ ] ; if ( preg_match_all ( $ this -> parameter_pattern , $ path , $ matches ) ) { foreach ... | Adds Custom Rewrite Rules . |
7,761 | public function add_tag ( $ tag = '' , $ regex = '' , $ force = false ) { if ( ! isset ( $ this -> rewrite_tag [ $ tag ] ) || isset ( $ this -> rewrite_tag [ $ tag ] ) && true === $ force ) { $ this -> rewrite_tag [ $ tag ] = $ regex ; } return $ this ; } | Adds Rewrite Tag . |
7,762 | public function add_query_vars ( $ vars = array ( ) ) { if ( ! empty ( $ this -> rewrite_endpoint ) ) { $ keys = array_keys ( $ this -> rewrite_endpoint ) ; return array_merge ( $ vars , $ keys ) ; } return $ vars ; } | Adds Custom Query Vars TO WordPress . |
7,763 | public function getStorageColumns ( ) { $ columns = $ this -> createStorageColumns ( ) ; $ namedColumns = [ ] ; foreach ( $ columns as $ column ) { $ namedColumns [ $ column -> columnName ] = $ column ; } return $ namedColumns ; } | Returns an array of named columns needed for storage . |
7,764 | final public function getRepositorySpecificColumn ( $ repositoryClassName ) { $ reposName = basename ( str_replace ( "\\" , "/" , $ repositoryClassName ) ) ; $ className = '\Rhubarb\Stem\Repositories\\' . $ reposName . '\Schema\Columns\\' . $ reposName . basename ( str_replace ( "\\" , "/" , get_class ( $ this ) ) ) ; ... | Returns a repository specific version of this column if one is available . |
7,765 | public function execute ( TransactionData $ transactionData , $ argument = null ) { if ( $ argument instanceof ClassArgumentObject ) { $ middleware = $ argument -> getInstance ( ) ; $ transactionData -> setResponse ( $ middleware ( $ transactionData -> getRequest ( ) , $ transactionData -> getResponse ( ) , $ argument ... | Executes a PSR - 7 middleware . |
7,766 | private function readFile ( ) { $ content = @ file_get_contents ( $ this -> filename ) ; if ( false === $ content ) { throw new InvalidArgumentException ( sprintf ( 'Cannot access "%s" to read the JSON file' , $ this -> filename ) ) ; } $ content = json_decode ( $ content , true ) ; if ( JSON_ERROR_NONE !== json_last_e... | Get the content of the json assets file . |
7,767 | private function getCachedContent ( ) { $ item = null ; if ( null !== $ this -> cache ) { $ item = $ this -> cache -> getItem ( $ this -> cacheKey ) ; $ cacheContent = $ item -> get ( ) ; if ( $ item -> isHit ( ) && null !== $ cacheContent ) { $ this -> contentCache = $ cacheContent ; } } return $ item ; } | Get the cached content . |
7,768 | private function saveContentInCache ( $ item , array $ content ) { if ( null !== $ this -> cache && null !== $ item ) { $ item -> set ( $ this -> contentCache ) ; $ this -> cache -> save ( $ item ) ; } return $ content ; } | Save the content in the cache and returns the content . |
7,769 | public function logboardAction ( $ token , Request $ request ) { $ this -> loadServices ( $ token , $ request ) ; if ( $ this -> queryManager -> isPreview ( ) ) return new Response ( $ this -> twig -> render ( "LogboardBundle:Collector:viewer.html.twig" , array ( 'logs_stack' => $ this -> profilerManager -> getPreviewD... | The Logboard controller |
7,770 | protected function loadServices ( $ token , Request $ request ) { $ this -> templates = $ this -> container -> getParameter ( 'data_collector.templates' ) ; $ this -> twig = $ this -> container -> get ( "twig" ) ; $ this -> accessor = PropertyAccess :: createPropertyAccessor ( ) ; $ this -> profilerManager = $ this -> ... | Loading the services |
7,771 | protected function setEngine ( ) { if ( null !== $ this -> engine ) { $ service = sprintf ( 'logboard.%s' , $ this -> engine ) ; if ( $ this -> container -> has ( $ service ) ) { $ this -> queryManager -> setEngine ( $ this -> container -> get ( $ service ) ) ; } else { throw new BadQueryHttpException ( sprintf ( 'The ... | Set the engine for queryManager |
7,772 | public function removeInvalidBlock ( Block $ block , $ reason = 'unknown' ) { foreach ( $ this as $ index => $ testBlock ) { if ( $ testBlock -> equals ( $ block ) ) { \ Log :: warn ( "Block {$block} removed as invalid with reason: {$reason}" ) ; $ this -> offsetUnset ( $ index ) ; } } } | Remove block marking as invalid |
7,773 | public function orderByPlaceHolderNameArray ( array $ placeHolderNames = null ) { if ( is_null ( $ placeHolderNames ) ) { return ; } $ blockArray = iterator_to_array ( $ this ) ; $ sortFunction = function ( Block $ block1 , Block $ block2 ) use ( $ placeHolderNames , $ blockArray ) { $ name1 = $ block1 -> getPlaceHolde... | Will order the blocks by the placeholder position leave the order for blocks inside the same placeholder . |
7,774 | private function isEventForMe ( GetOptionsEvent $ event ) { $ input = $ event -> getEnvironment ( ) -> getInputProvider ( ) ; if ( $ input -> hasValue ( 'type' ) ) { $ type = $ input -> getValue ( 'type' ) ; } if ( empty ( $ type ) ) { $ type = $ event -> getModel ( ) -> getProperty ( 'type' ) ; } return ( $ event -> g... | Check if the event is intended for us . |
7,775 | public static function truncateHTML ( $ html , $ maxLength , $ trailing = '...' ) { $ html = trim ( $ html ) ; $ printedLength = 0 ; $ position = 0 ; $ tags = [ ] ; $ res = '' ; while ( $ printedLength < $ maxLength && preg_match ( '{</?([a-z]+)[^>]*>|&#?[a-zA-Z0-9]+;}' , $ html , $ match , PREG_OFFSET_CAPTURE , $ posi... | Truncate HTML code . |
7,776 | public static function truncate ( $ str , $ length , $ trailing = '...' ) { $ length -= mb_strlen ( $ trailing ) ; if ( mb_strlen ( $ str ) > $ length ) return mb_substr ( $ str , 0 , $ length ) . $ trailing ; return $ str ; } | Truncate a string . |
7,777 | public static function truncateWords ( $ str , $ length , $ trailing = '...' ) { $ words = explode ( ' ' , $ str ) ; $ cutwords = array_slice ( $ words , 0 , $ length ) ; return implode ( ' ' , $ cutwords ) . ( count ( $ words ) > count ( $ cutwords ) ? $ trailing : '' ) ; } | Truncate a string by words . |
7,778 | public static function loadClassFile ( $ file ) { $ before = array_merge ( get_declared_classes ( ) , get_declared_interfaces ( ) ) ; require_once $ file ; $ after = array_merge ( get_declared_classes ( ) , get_declared_interfaces ( ) ) ; $ diff = array_diff ( $ after , $ before ) ; if ( ! $ diff ) { foreach ( array_me... | Load a file and return the class contained in the file . |
7,779 | public function save ( Layout $ layout ) { $ archiveDir = $ this -> getUploadDir ( ) . '/archives' ; $ templateDir = $ this -> getUploadDir ( ) . '/templates' ; $ tmpDir = $ this -> getUploadDir ( ) . '/tmp/' . time ( ) ; $ file = $ layout -> getFile ( ) -> move ( $ archiveDir , $ layout -> getFile ( ) -> getClientOrig... | Persist template and move zip archive s elements . |
7,780 | protected function moveFiles ( $ extension , $ actualDir , $ targetDir , $ throwExceptionIfNotFound = true ) { if ( ! is_array ( $ extension ) ) { $ extension = ( array ) $ extension ; } $ finder = new Finder ( ) ; $ finder -> files ( ) -> in ( $ actualDir ) ; foreach ( $ extension as $ ext ) { $ finder -> name ( $ ext... | Move files of extension type . |
7,781 | protected function readConfiguration ( $ actualDir ) { $ finder = new Finder ( ) ; $ finder -> files ( ) -> in ( $ actualDir ) -> name ( '*.yml' ) ; if ( iterator_count ( $ finder ) < 1 ) { throw new \ Exception ( 'The configuration (.yml) file is missing.' ) ; } $ files = iterator_to_array ( $ finder ) ; $ file = curr... | Return an array from the configuration yml file . |
7,782 | private function getDirectories ( $ dir , $ directoryName = null ) { $ finder = new Finder ( ) ; $ finder -> directories ( ) -> in ( $ dir ) ; if ( null !== $ directoryName ) { $ finder -> name ( $ directoryName ) ; } if ( iterator_count ( $ finder ) > 0 ) { return iterator_to_array ( $ finder ) ; } return false ; } | Get directories . |
7,783 | public static function createAdminRole ( $ force = false ) { if ( ! $ force ) { if ( Permission :: exists ( 'global' , 'admin' ) ) { return false ; } } return self :: createRole ( 'Admin' , true , [ [ 'app' => 'global' , 'key' => 'admin' ] ] ) ; } | Create an Admin role . |
7,784 | public static function createEditorRole ( $ force = false ) { if ( ! $ force ) { if ( Permission :: exists ( 'global' , 'editor' ) ) { return false ; } } return self :: createRole ( 'Editor' , true , [ [ 'app' => 'global' , 'key' => 'editor' ] ] ) ; } | Create an Editor role . |
7,785 | public static function createAuthorRole ( $ force = false ) { if ( ! $ force ) { if ( Permission :: exists ( 'global' , 'author' ) ) { return false ; } } return self :: createRole ( 'Author' , true , [ [ 'app' => 'global' , 'key' => 'author' ] ] ) ; } | Create an Author role . |
7,786 | public static function createRole ( $ name , $ isDefault , $ permissions = [ ] ) { $ role = ( new static ( ) ) ; $ role -> name = $ name ; $ role -> isDefault = $ isDefault ; $ role -> slug = str_slug ( $ name ) ; if ( $ createdRole = $ role -> save ( ) ) { if ( $ permissions ) { $ permissionObj = new Permission ( ) ; ... | Create an admin role . |
7,787 | public function setNewlineTokenName ( string $ name ) : BasicLexer { if ( strlen ( $ name ) == 0 ) { throw new \ InvalidArgumentException ( 'The name of the newline token must be not empty.' ) ; } $ this -> newlineTokenName = $ name ; return $ this ; } | Sets the name of the newline token |
7,788 | public function setEosTokenName ( string $ name ) : BasicLexer { if ( strlen ( $ name ) == 0 ) { throw new \ InvalidArgumentException ( 'The name of the EOS token must be not empty.' ) ; } $ this -> eosTokenName = $ name ; return $ this ; } | Sets the name of the end - of - string token |
7,789 | protected function match ( string $ line , int $ lineNumber , int $ offset ) : array { $ restLine = substr ( $ line , $ offset ) ; foreach ( $ this -> terminals as $ pattern => $ name ) { if ( preg_match ( $ pattern , $ restLine , $ matches ) ) { return [ $ name , $ matches , ] ; } } throw new SyntaxErrorException ( sp... | Returns the first match with the list of terminals |
7,790 | public function autoMigrate ( $ definitions ) { if ( ! is_array ( $ definitions ) ) $ definitions = [ $ definitions ] ; $ entitiesSchema = $ this -> getEntitiesSchemas ( $ definitions ) ; $ sqlSchema = $ this -> getSQLSchemas ( ) ; $ this -> processSchemas ( $ entitiesSchema , $ sqlSchema ) ; } | Automatically migrate given entity definitions . |
7,791 | public function generateMigration ( $ definitions , $ migrationName ) { if ( ! is_array ( $ definitions ) ) $ definitions = [ $ definitions ] ; $ entitiesSchema = $ this -> getEntitiesSchemas ( $ definitions ) ; $ sqlSchema = $ this -> getSQLSchemas ( ) ; $ up = $ this -> buildMigration ( $ entitiesSchema , $ sqlSchema... | Generate a migration from given entity definitions . |
7,792 | public function previewMigration ( $ definitions , $ migrationName ) { if ( ! is_array ( $ definitions ) ) $ definitions = [ $ definitions ] ; $ entitiesSchema = $ this -> getEntitiesSchemas ( $ definitions ) ; $ sqlSchema = $ this -> getSQLSchemas ( ) ; $ up = $ this -> buildMigration ( $ entitiesSchema , $ sqlSchema ... | Generate a migration preview from given entity definitions . |
7,793 | protected function processSchemas ( \ Doctrine \ DBAL \ Schema \ Schema $ newSchema , \ Doctrine \ DBAL \ Schema \ Schema $ oldSchema ) { $ comparator = new \ Doctrine \ DBAL \ Schema \ Comparator ; $ schemaDiff = $ comparator -> compare ( $ oldSchema , $ newSchema ) ; $ platform = $ this -> dataMapper -> getDB ( ) -> ... | Process the schemas . |
7,794 | protected function buildMigration ( \ Doctrine \ DBAL \ Schema \ Schema $ newSchema , \ Doctrine \ DBAL \ Schema \ Schema $ oldSchema , $ drop ) { $ comparator = new \ Doctrine \ DBAL \ Schema \ Comparator ; $ schemaDiff = $ comparator -> compare ( $ oldSchema , $ newSchema ) ; $ res = '' ; if ( $ drop ) { foreach ( $ ... | Build the migration code by comparing the new schemas to the old ones . |
7,795 | protected function renameColumn ( $ name , \ Doctrine \ DBAL \ Schema \ Column $ col ) { $ res = "\n\t\$table->rename('$name', '" . $ col -> getName ( ) . "');" ; return $ res ; } | Generate code to rename a column . |
7,796 | protected function createTable ( $ tableName , $ table ) { $ res = "\$this->schema->create('$tableName', function(\$table) {" ; foreach ( $ table -> getColumns ( ) as $ colName => $ col ) $ res .= $ this -> createColumn ( $ colName , $ col ) ; foreach ( $ table -> getIndexes ( ) as $ index ) $ res .= $ this -> createIn... | Generate code to create a table . |
7,797 | protected function updateColumn ( $ name , \ Doctrine \ DBAL \ Schema \ ColumnDiff $ col ) { $ res = "\n\t\$table->changeColumn('$name', [" ; $ type_changed = in_array ( 'type' , $ col -> changedProperties ) ; foreach ( $ col -> column -> toArray ( ) as $ propName => $ prop ) { if ( ( $ type_changed && $ prop && $ prop... | Generate the code to update a column . |
7,798 | protected function createColumn ( $ name , \ Doctrine \ DBAL \ Schema \ Column $ col ) { $ type = strtolower ( $ col -> getType ( ) ) ; $ res = "\n\t\$table->addColumn('$name', '" . $ type . "', [" ; if ( $ col -> getNotnull ( ) ) $ res .= "\n 'notnull' => true," ; if ( $ col -> getAutoincrement ( ) ) $ res .= "\n 'a... | Generate the code to create a column . |
7,799 | protected function createIndex ( $ index ) { if ( $ index -> isPrimary ( ) ) $ res = "\n\t\$table->setPrimaryKey(\n\t\t" . $ this -> outputPHP ( $ index -> getColumns ( ) , 2 ) . ",\n\t\t'" . $ index -> getName ( ) . "'\n\t);" ; elseif ( $ index -> isUnique ( ) ) $ res = "\n\t\$table->addUniqueIndex(\n\t\t" . $ this ->... | Build an index . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.