idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
55,600 | public function setAddChildrenIfNoneSet ( $ children = array ( 'defaults' ) ) { if ( null === $ children ) { $ this -> defaultChildren = array ( 'defaults' ) ; } else { $ this -> defaultChildren = is_int ( $ children ) && $ children > 0 ? range ( 1 , $ children ) : ( array ) $ children ; } } | Adds default children when none are set . |
55,601 | public function prefix ( $ prefix = null ) { if ( null !== $ prefix ) { $ this -> prefix = substr ( md5 ( $ prefix ) , 0 , 10 ) . '_' ; } return $ this -> prefix ; } | Define prefix for Cache Application and return it . |
55,602 | public function destroy ( $ reopen = false ) { if ( $ this -> isOpen ) { $ params = session_get_cookie_params ( ) ; setcookie ( session_name ( ) , '' , time ( ) - 42000 , $ params [ 'path' ] , $ params [ 'domain' ] , $ params [ 'secure' ] , $ params [ 'httponly' ] ) ; session_destroy ( ) ; $ this -> isOpen = false ; } ... | Destroys the current session and its data . |
55,603 | public function open ( $ data = null ) { if ( ! session_start ( ) ) { throw new \ RuntimeException ( 'Could not open session.' ) ; } session_regenerate_id ( true ) ; $ this -> isOpen = true ; if ( $ data === null ) { if ( $ this -> data === null ) { $ data = & $ _SESSION ; } else { $ this -> flashStorage -> decrement (... | Starts the session . Regenerates the session ID each request for security reasons and updates flash variables . |
55,604 | public function sessionName ( $ name = null ) { if ( $ name === null ) { return session_name ( ) ; } if ( $ this -> isOpen ) { throw new \ InvalidArgumentException ( 'The session has already been opened.' ) ; } if ( ! is_string ( $ name ) ) { throw new \ InvalidArgumentException ( 'Session name must be null or a string... | Sets or gets the session name . |
55,605 | public function savePath ( $ path = null ) { if ( $ path === null ) { return session_save_path ( ) ; } if ( $ this -> isOpen ) { throw new \ InvalidArgumentException ( 'The session has already been opened.' ) ; } if ( ! is_string ( $ path ) ) { throw new \ InvalidArgumentException ( 'Session path must be null or a stri... | Sets or gets the current session save path . |
55,606 | public function trigger ( $ eventName , $ arg1 = 'NULLPARAMETER' ) { $ this -> Logger -> debug ( 'Triggering event [' . $ eventName . ']' ) ; if ( ( $ event = $ this -> ApplicationContext -> getEvent ( $ eventName ) ) == false ) return ; $ args = array ( ) ; $ stack = null ; if ( $ arg1 !== 'NULLPARAMETER' ) { if ( PHP... | Trigger the event passing parameters to callbacks |
55,607 | public function createFolder ( $ folder , $ allFolders = FALSE ) { if ( substr ( $ folder , - 1 ) != '/' ) $ folder = $ folder . '/' ; if ( ! is_dir ( $ folder ) ) { @ mkdir ( $ folder , 0777 , $ allFolders ) or die ( "Error creating folder '{$folder}'." ) ; } } | To create a new folder |
55,608 | public function moveFile ( $ file , $ originalFolder , $ newFolder ) { if ( substr ( $ originalFolder , - 1 ) != '/' ) $ originalFolder = $ originalFolder . '/' ; if ( substr ( $ newFolder , - 1 ) != '/' ) $ newFolder = $ newFolder . '/' ; $ this -> copyFile ( $ originalFolder . $ file , $ newFolder . $ file ) ; $ this... | To move a file |
55,609 | public function copyFile ( $ originalFile , $ newFile ) { if ( is_file ( $ originalFile ) ) { @ copy ( $ originalFile , $ newFile ) or die ( "File '{$originalFile}' can't be copied to '{$newFile}'." ) ; } else { die ( "File '{$originalFile}' doesn't exist." ) ; } } | To copy a file |
55,610 | public function readFolder ( $ folder , $ sort = 0 ) { if ( substr ( $ folder , - 1 ) != '/' ) $ folder = $ folder . '/' ; $ this -> data = @ scandir ( $ folder , $ sort ) or die ( "Error reading folder: '{$folder}'." ) ; $ this -> numberOfFiles = count ( $ this -> data ) ; } | Reading the files and folders of a certain folder |
55,611 | public function processUploadedFile ( $ originalFile , $ newFile , $ folder ) { if ( substr ( $ folder , - 1 ) != '/' ) $ folder = $ folder . '/' ; @ move_uploaded_file ( $ originalFile , $ folder . $ newFile ) or die ( "File: '{$originalFile}' couldn't be moved '{$folder}'." ) ; @ chmod ( $ folder . $ newFile , 0777 )... | Process an uploaded file and moved to a folder on the server |
55,612 | public function findOrNew ( $ id , $ columns = [ '*' ] ) { if ( is_null ( $ instance = $ this -> find ( $ id , $ columns ) ) ) { $ instance = $ this -> related -> newInstance ( ) ; $ instance -> setAttribute ( $ this -> getPlainForeignKey ( ) , $ this -> getParentKey ( ) ) ; } return $ instance ; } | Find a model by its primary key or return new instance of the related model . |
55,613 | public function tokenize ( $ callback = null ) { $ this -> reset ( ) ; if ( ! is_callable ( $ callback ) ) { $ callback = function ( ) { } ; } for ( $ line = 1 , $ i = 0 ; $ i < $ this -> strlen ; $ i ++ ) { if ( mb_substr ( $ this -> source , $ i , 1 ) === "\n" ) { $ line ++ ; } switch ( true ) { case mb_substr ( $ th... | Main rendering function that passes tokens to the supplied callback . |
55,614 | protected function addNode ( int $ start , string $ type , int $ line , int $ offset1 , int $ offset2 , $ callback ) { $ this -> flushText ( $ start , $ callback ) ; switch ( $ type ) { case self :: TYPE_VARIABLE_ESCAPE : $ end = $ this -> findVariable ( $ start , true ) ; break ; case self :: TYPE_VARIABLE_UNESCAPE : ... | Forms the node and passes to the callback |
55,615 | protected function findVariable ( int $ i , bool $ escape ) : int { $ close = ( $ escape === true ? '}}}' : '}}' ) ; for ( ; mb_substr ( $ this -> source , $ i , mb_strlen ( $ close ) ) !== $ close ; $ i ++ ) { } return $ i + mb_strlen ( $ close ) ; } | Since we know where the start is we need to find the end in the source . |
55,616 | protected function save ( $ origin , $ short = null ) { $ shortener = Shortener :: updateOrCreate ( [ 'hash' => hash ( 'sha512' , $ origin ) ] , [ 'url' => $ origin , 'short' => $ short ] ) ; return $ shortener -> exists ? $ shortener -> getKey ( ) : false ; } | Save record to database . |
55,617 | public function addColumnName ( $ columnName ) { if ( ! is_string ( $ columnName ) || ( strlen ( $ columnName ) <= 0 ) ) { throw SchemaException :: invalidIndexColumnName ( $ this -> getName ( ) ) ; } $ this -> columnNames [ ] = $ columnName ; } | Adds a column name to the index . |
55,618 | public function setUnique ( $ unique ) { if ( ! is_bool ( $ unique ) ) { throw SchemaException :: invalidIndexUniqueFlag ( $ this -> getName ( ) ) ; } $ this -> unique = $ unique ; } | Sets the unique index flag . |
55,619 | public function isBetterThan ( Index $ index ) { if ( $ this -> hasSameColumnNames ( $ index -> getColumnNames ( ) ) && $ this -> isUnique ( ) && ! $ index -> isUnique ( ) ) { return true ; } return false ; } | Checks if the index is better than the given index . Better means the index can replace the given . |
55,620 | private function createUser ( $ sendEmail = true ) { $ model = new RegisterForm ; if ( ! empty ( $ _POST ) ) { $ model -> attributes = $ _POST ; if ( $ model -> save ( $ sendEmail ) ) return Users :: model ( ) -> findByAttributes ( array ( 'email' => $ _POST [ 'email' ] ) ) -> getAPIAttributes ( array ( 'password' ) , ... | Utilizes the registration form to create a new user |
55,621 | public function handle ( $ errorLevel , $ message , $ file , $ line , $ context ) { if ( $ this -> errorLevel === 0 ) { return FALSE ; } if ( $ this -> displayErrors && error_reporting ( ) & $ errorLevel && $ this -> errorLevel & $ errorLevel ) { throw new \ ErrorException ( sprintf ( '%s: %s in %s line %d' , isset ( $... | handle error and throw exception when error level limits are met |
55,622 | public function setTemplatePath ( $ path , \ Twig_Environment $ twig = null , $ extensions = [ ] ) { $ this -> paths [ 'templates' ] = $ path ; if ( is_null ( $ twig ) === true ) { $ loader = new \ Twig_Loader_Filesystem ( $ path ) ; $ twig = new \ Twig_Environment ( $ loader ) ; } $ twig -> setExtensions ( $ extension... | Sets the templates path . |
55,623 | public function run ( $ console = false ) { $ instance = $ this -> console ( ) ; return $ console ? $ instance : $ instance -> run ( ) ; } | Runs the current console . |
55,624 | protected function console ( ) { $ files = glob ( $ this -> getCommandPath ( ) . '/*.php' ) ; $ path = strlen ( $ this -> getCommandPath ( ) . DIRECTORY_SEPARATOR ) ; $ pattern = '/\\.[^.\\s]{3,4}$/' ; foreach ( ( array ) $ files as $ file ) { $ class = preg_replace ( $ pattern , '' , substr ( $ file , $ path ) ) ; $ c... | Sets up Twig and gets all commands from the specified path . |
55,625 | public function createMap ( ... $ paths ) { $ classes = [ ] ; $ this -> finder -> files ( ) -> ignoreUnreadableDirs ( ) -> in ( $ paths ) ; foreach ( $ this -> excludePathPatterns as $ exclude ) { $ this -> finder -> notPath ( $ exclude ) ; } foreach ( $ this -> inPathPatterns as $ inPath ) { $ this -> finder -> path (... | Create a map for a given path |
55,626 | public function compare ( Column $ oldColumn , Column $ newColumn ) { $ differences = array ( ) ; if ( $ oldColumn -> getType ( ) !== $ newColumn -> getType ( ) ) { $ differences [ ] = 'type' ; } if ( $ oldColumn -> getLength ( ) !== $ newColumn -> getLength ( ) ) { $ differences [ ] = 'length' ; } if ( $ oldColumn -> ... | Compares two columns . |
55,627 | public function scopePublishedAt ( Builder $ query , $ year ) { return $ this -> scopePublished ( $ query ) -> where ( DB :: raw ( 'YEAR(published_at)' ) , $ year ) ; } | Scope only published posts . |
55,628 | protected static function extractSeoAttributes ( array $ inputs ) { return [ 'title' => Arr :: get ( $ inputs , 'seo_title' ) , 'description' => Arr :: get ( $ inputs , 'seo_description' ) , 'keywords' => Arr :: get ( $ inputs , 'seo_keywords' ) , 'metas' => Arr :: get ( $ inputs , 'seo_metas' , [ ] ) , ] ; } | Extract the seo attributes . |
55,629 | public static function identify_service ( $ url ) { if ( preg_match ( '%youtube|youtu\.be%i' , $ url ) ) { return self :: YOUTUBE ; } elseif ( preg_match ( '%vimeo%i' , $ url ) ) { return self :: VIMEO ; } elseif ( preg_match ( '%23video%' , $ url ) ) { return self :: TWENTYTHREE ; } return null ; } | Determines which cloud video provider is being used based on the passed url . |
55,630 | public static function get_url_id ( $ url ) { $ service = self :: identify_service ( $ url ) ; if ( $ service == self :: YOUTUBE ) { return self :: get_youtube_id ( $ url ) ; } elseif ( $ service == self :: VIMEO ) { return self :: get_vimeo_id ( $ url ) ; } elseif ( $ service == self :: TWENTYTHREE ) { return self :: ... | Determines which cloud video provider is being used based on the passed url and extracts the video id from the url . |
55,631 | public static function get_url_embed ( $ url ) { $ service = self :: identify_service ( $ url ) ; $ id = self :: get_url_id ( $ url ) ; if ( $ service == self :: YOUTUBE ) { return self :: get_youtube_embed ( $ id ) ; } elseif ( $ service == self :: VIMEO ) { return self :: get_vimeo_embed ( $ id ) ; } elseif ( $ servi... | Determines which cloud video provider is being used based on the passed url extracts the video id from the url and builds an embed url . |
55,632 | public static function get_youtube_id ( $ input ) { if ( preg_match ( '#/embed/([^\?&"]+)#' , $ input , $ matches ) ) { return $ matches [ 1 ] ; } if ( preg_match ( '#vi?=([^&]+)#' , $ input , $ matches ) ) { return $ matches [ 1 ] ; } if ( preg_match ( '#//youtu.be/([^\?&"/]+)#' , $ input , $ matches ) ) { return $ ma... | Parses various youtube urls and returns video identifier . |
55,633 | public static function get_vimeo_id ( $ input ) { if ( preg_match ( '#/vimeo.com/(\d+)#' , $ input , $ matches ) ) { return $ matches [ 1 ] ; } if ( preg_match ( '#/video/(\d+)#' , $ input , $ matches ) ) { return $ matches [ 1 ] ; } return null ; } | Parses various vimeo urls and returns video identifier . |
55,634 | public function findAllWithAspect ( $ aspectName , $ restrictSiteSlug = null ) { $ dto = new DTO ( ) ; $ dto -> setParameter ( "IncludesAspect" , ltrim ( $ aspectName , '@' ) ) ; if ( ! is_null ( $ restrictSiteSlug ) ) $ dto -> setParameter ( "AnchoredSiteSlug" , $ restrictSiteSlug ) ; $ dto = $ this -> findAll ( $ dto... | Returns all elements that have the specified aspect |
55,635 | public function findAllFromString ( $ aspectsOrElements ) { $ results = array ( ) ; foreach ( explode ( ',' , $ aspectsOrElements ) as $ aspectOrElement ) { $ aspectOrElement = trim ( $ aspectOrElement ) ; if ( substr ( $ aspectOrElement , 0 , 1 ) == '@' ) { $ els = $ this -> findAllWithAspect ( $ aspectOrElement ) ; f... | Returns all elements for given aspect names and element slugs |
55,636 | public function read ( $ byteCount , $ allowIncomplete = false ) { $ maxByteCount = $ this -> getRemainingByteCount ( ) ; if ( ! $ allowIncomplete && $ maxByteCount < $ byteCount ) { throw new Exception \ UnderflowException ( 'The source doesn\'t have enough remaining data to fulfill the request' ) ; } $ byteCount = ma... | Reads and consumes data from the source . |
55,637 | static public function set ( $ key , $ value ) { $ config = & self :: $ _config ; Utils :: arraySet ( $ config , $ key , $ value ) ; } | Add or set configuration key |
55,638 | private function AddTitleField ( ) { $ name = 'Title' ; $ this -> AddField ( Input :: Text ( $ name , $ this -> page -> GetTitle ( ) ) ) ; } | Adds the title field to the form |
55,639 | private function AddDescriptionField ( ) { $ name = 'Description' ; $ this -> AddField ( Input :: Text ( $ name , $ this -> page -> GetDescription ( ) ) ) ; } | Adds the description field to the form |
55,640 | private function AddKeywordsField ( ) { $ name = 'Keywords' ; $ this -> AddField ( Input :: Text ( $ name , $ this -> page -> GetKeywords ( ) ) ) ; } | Adds the keywords field to the form |
55,641 | private function AddLayoutField ( ) { $ name = 'Layout' ; $ select = new Select ( $ name ) ; if ( $ this -> page -> Exists ( ) ) { $ select -> SetValue ( $ this -> page -> GetLayout ( ) -> GetID ( ) ) ; } $ select -> AddOption ( '' , Trans ( 'Core.PleaseSelect' ) ) ; $ sql = Access :: SqlBuilder ( ) ; $ tbl = Layout ::... | Adds the layout field to the form |
55,642 | private function AddMenuAccessField ( ) { $ name = 'MenuAccess' ; $ value = $ this -> page -> Exists ( ) ? $ this -> page -> GetMenuAccess ( ) : ( string ) MenuAccess :: Authorized ( ) ; $ select = new Select ( $ name , $ value ) ; foreach ( MenuAccess :: AllowedValues ( ) as $ access ) { $ select -> AddOption ( $ acce... | Adds the menu access select |
55,643 | private function AddPublishToHourField ( ) { $ name = 'PublishToHour' ; $ to = $ this -> page -> GetPublishTo ( ) ; $ field = Input :: Text ( $ name , $ to ? $ to -> ToString ( 'H' ) : '' ) ; $ field -> SetHtmlAttribute ( 'data-type' , 'hour' ) ; $ this -> AddField ( $ field ) ; } | Adds the publish to hour field |
55,644 | private function AddSitemapRelevanceField ( ) { $ name = 'SitemapRelevance' ; $ value = $ this -> page -> Exists ( ) ? 10 * $ this -> page -> GetSitemapRelevance ( ) : 7 ; $ field = new Select ( $ name , $ value ) ; for ( $ val = 0 ; $ val <= 10 ; ++ $ val ) { $ decSep = Trans ( 'Core.DecimalSeparator' ) ; $ thousSep =... | Adds the sitemap relevance field |
55,645 | private function AddSitemapChangeFrequencyField ( ) { $ name = 'SitemapChangeFrequency' ; $ value = $ this -> page -> Exists ( ) ? $ this -> page -> GetSitemapChangeFrequency ( ) : ( string ) ChangeFrequency :: Weekly ( ) ; $ field = new Select ( $ name , $ value ) ; $ values = ChangeFrequency :: AllowedValues ( ) ; fo... | Adds the sitemap change frequency field |
55,646 | protected function OnSuccess ( ) { $ prevLayout = $ this -> page -> GetLayout ( ) ; $ this -> page -> SetName ( $ this -> Value ( 'Name' ) ) ; $ this -> page -> SetUrl ( $ this -> Value ( 'Url' ) ) ; $ this -> page -> SetSite ( $ this -> site ) ; $ this -> page -> SetTitle ( $ this -> Value ( 'Title' ) ) ; $ this -> pa... | Saves the page |
55,647 | private function ReassignContents ( Layout $ prevLayout , Layout $ newLayout ) { if ( $ prevLayout -> Equals ( $ newLayout ) ) { return ; } $ oldAreas = Area :: Schema ( ) -> FetchByLayout ( false , $ prevLayout ) ; foreach ( $ oldAreas as $ oldArea ) { $ newArea = $ this -> FindNewArea ( $ oldArea , $ newLayout ) ; if... | Reassigns contents by area names if layout was changed |
55,648 | private function SaveRights ( ) { $ groupID = $ this -> Value ( 'UserGroup' ) ; $ userGroup = Usergroup :: Schema ( ) -> ByID ( $ groupID ) ; $ this -> page -> SetUserGroup ( $ userGroup ) ; if ( ! $ userGroup ) { $ oldRights = $ this -> page -> GetUserGroupRights ( ) ; if ( $ oldRights ) { $ oldRights -> GetContentRig... | Saves the group and right settings |
55,649 | private function SaveMemberGroups ( ) { $ selectedIDs = Request :: PostArray ( 'MemberGroup' ) ; if ( $ this -> page -> GetGuestsOnly ( ) ) { $ selectedIDs = array ( ) ; } $ exIDs = Membergroup :: GetKeyList ( MembergroupUtil :: PageMembergroups ( $ this -> page ) ) ; $ this -> DeleteOldMemberGroups ( $ selectedIDs ) ;... | Saves the member groups |
55,650 | private function DeleteOldMemberGroups ( array $ selectedIDs ) { $ sql = Access :: SqlBuilder ( ) ; $ tblPgGrp = PageMembergroup :: Schema ( ) -> Table ( ) ; $ where = $ sql -> Equals ( $ tblPgGrp -> Field ( 'Page' ) , $ sql -> Value ( $ this -> page -> GetID ( ) ) ) ; if ( count ( $ selectedIDs ) ) { $ inSelected = $ ... | Deletes the old member groups |
55,651 | private function SaveNewMemberGroups ( array $ selectedIDs , array $ exIDs ) { foreach ( $ selectedIDs as $ selID ) { if ( ! in_array ( $ selID , $ exIDs ) ) { $ pgGrp = new PageMembergroup ( ) ; $ pgGrp -> SetPage ( $ this -> page ) ; $ pgGrp -> SetMemberGroup ( new Membergroup ( $ selID ) ) ; $ pgGrp -> Save ( ) ; } ... | Saves page member groups not already assigned |
55,652 | private function SaveNew ( ) { $ treeBuilder = new TreeBuilder ( new PageTreeProvider ( $ this -> site ) ) ; $ treeBuilder -> Insert ( $ this -> page , $ this -> parent , $ this -> previous ) ; } | Takes care of page tree insertion important for a fresh page |
55,653 | private function AdjustHtaccess ( ) { $ file = Path :: Combine ( PHINE_PATH , 'Public/.htaccess' ) ; if ( ! File :: Exists ( $ file ) ) { throw new \ Exception ( 'HTACCESS FILE $file NOT FOUND' ) ; } $ writer = new Writer ( ) ; $ rewriter = new Rewriter ( $ writer ) ; $ text = File :: GetContents ( $ file ) ; $ startPo... | Adds necessary rewrite commands |
55,654 | public function get ( $ idOrDocument ) { $ modelFetcher = $ this -> getServiceLocator ( ) -> get ( 'document.model.fetcher' ) ; $ this -> getEventManager ( ) -> trigger ( __FUNCTION__ , $ this , array ( 'document' => $ idOrDocument ) ) ; $ classifiedModel = $ modelFetcher -> get ( $ idOrDocument ) ; $ this -> getEventM... | Get a classified model |
55,655 | public function expired ( $ limit = 10 ) { $ main = $ this -> getServiceLocator ( ) -> get ( 'neobazaar.service.main' ) ; $ em = $ main -> getEntityManager ( ) ; $ cache = $ this -> getServiceLocator ( ) -> get ( 'ClassifiedCache' ) ; $ documentRepository = $ main -> getDocumentEntityRepository ( ) ; $ documents = $ do... | This service will trigger event with expired classifieds . anything binded with these events will run |
55,656 | public function activationEmailResend ( $ limit = 10 ) { $ main = $ this -> getServiceLocator ( ) -> get ( 'neobazaar.service.main' ) ; $ em = $ main -> getEntityManager ( ) ; $ cache = $ this -> getServiceLocator ( ) -> get ( 'ClassifiedCache' ) ; $ documentRepository = $ main -> getDocumentEntityRepository ( ) ; $ do... | This service will trigger event with classifieds that needs activetion email to be resent . |
55,657 | public static function indent ( $ lines , $ cnt = 1 ) { $ new = [ ] ; $ lines = str_contains ( $ lines , '\r\n' ) ? explode ( "\r\n" , $ lines ) : explode ( "\n" , $ lines ) ; foreach ( $ lines as $ line ) $ new [ ] = str_repeat ( "\t" , $ cnt ) . $ line ; return implode ( "\n" , $ new ) ; } | Indents each line |
55,658 | public static function prependLines ( $ lines , $ prepend , $ prependFirstLine = false ) { $ new = [ ] ; $ lines = str_contains ( $ lines , '\r\n' ) ? explode ( "\r\n" , $ lines ) : explode ( "\n" , $ lines ) ; if ( ! $ prependFirstLine ) $ new [ ] = $ lines [ 0 ] ; for ( $ i = $ prependFirstLine ? 0 : 1 ; $ i < count ... | Prepends each line |
55,659 | public static function getCode ( $ val , $ alpha3 = false ) { if ( self :: $ _countryFlip === array ( ) ) { self :: $ _countryFlip = array_flip ( self :: $ _countries ) ; } if ( ! array_key_exists ( $ val , self :: $ _countryFlip ) ) { return null ; } $ result = self :: $ _countryFlip [ $ val ] ; if ( $ alpha3 ) { retu... | Converts a KlarnaCountry constant to the respective country code . |
55,660 | public static function checkLanguage ( $ country , $ language ) { switch ( $ country ) { case KlarnaCountry :: AT : case KlarnaCountry :: DE : return ( $ language === KlarnaLanguage :: DE ) ; case KlarnaCountry :: NL : return ( $ language === KlarnaLanguage :: NL ) ; case KlarnaCountry :: FI : return ( $ language === K... | Checks country against currency and returns true if they match . |
55,661 | public static function checkCurrency ( $ country , $ currency ) { switch ( $ country ) { case KlarnaCountry :: AT : case KlarnaCountry :: DE : case KlarnaCountry :: NL : case KlarnaCountry :: FI : return ( $ currency === KlarnaCurrency :: EUR ) ; case KlarnaCountry :: DK : return ( $ currency === KlarnaCurrency :: DKK ... | Checks country against language and returns true if they match . |
55,662 | public static function getLanguage ( $ country ) { switch ( $ country ) { case KlarnaCountry :: AT : case KlarnaCountry :: DE : return KlarnaLanguage :: DE ; case KlarnaCountry :: NL : return KlarnaLanguage :: NL ; case KlarnaCountry :: FI : return KlarnaLanguage :: FI ; case KlarnaCountry :: DK : return KlarnaLanguage... | Get language for supplied country . Defaults to English . |
55,663 | public function isStringType ( ) { $ stringTypeList = [ 'char' , 'varchar' , 'tinyblob' , 'blob' , 'mediumblob' , 'longblob' , 'tinytext' , 'text' , 'mediumtext' , 'longtext' ] ; $ isString = false ; $ type = trim ( strtolower ( $ this -> getType ( ) ) ) ; foreach ( $ stringTypeList as $ stringType ) { if ( substr ( $ ... | Returns true if the column is a string type . |
55,664 | protected function _createInvalidArgumentException ( $ message = null , $ code = null , RootException $ previous = null , $ argument = null ) { return new InvalidArgumentException ( $ message , $ code , $ previous , $ argument ) ; } | Creates a new Dhii invalid argument exception . |
55,665 | private function createPage ( $ page , $ options , $ models ) { $ request = $ this -> getRequest ( ) ; if ( $ request -> getMethod ( ) == 'POST' ) { $ data = $ request -> get ( 'page' ) ; $ page -> setModel ( $ data [ 'model' ] ) ; } $ formClassName = isset ( $ models [ $ page -> getModel ( ) ] [ 'back' ] [ 'form' ] ) ... | Create form for page entity use for edit or add page |
55,666 | public function removeAction ( $ pageId ) { $ page = $ this -> getPage ( $ pageId ) ; if ( $ page -> getSlug ( ) == '' ) { throw new AccessDeniedException ( ) ; } $ request = $ this -> getRequest ( ) ; if ( $ request -> request -> get ( 'confirm' ) === 'yes' ) { if ( $ this -> container -> getParameter ( 'fulgurio_ligh... | Remove page with confirm form |
55,667 | public function copyAction ( $ sourceId , $ targetId , $ lang ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ source = $ this -> getPage ( $ sourceId ) ; $ target = $ this -> getPage ( $ targetId ) ; $ newPage = clone ( $ source ) ; $ newPage -> setParent ( $ target ) ; if ( $ target -> getLang ( ) ) { $ new... | Page copy use for multilang site |
55,668 | public function changePositionAction ( ) { $ request = $ this -> getRequest ( ) ; if ( $ request -> isXmlHttpRequest ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ pageRepository = $ this -> getDoctrine ( ) -> getRepository ( 'FulgurioLightCMSBundle:Page' ) ; $ page = $ this -> getPage ( $ request -> re... | Change page position using ajax tree |
55,669 | private function getPageMetas ( $ pageId ) { $ pageMetas = array ( ) ; $ metas = $ this -> getDoctrine ( ) -> getRepository ( 'FulgurioLightCMSBundle:PageMeta' ) -> findByPage ( $ pageId ) ; foreach ( $ metas as $ meta ) { $ pageMetas [ $ meta -> getMetaKey ( ) ] = $ meta ; } return $ pageMetas ; } | Get meta data from given ID page |
55,670 | public function add ( ) { if ( ! $ args = func_get_args ( ) ) { return $ this ; } $ intervals = array_map ( array ( $ this , 'addHelper' ) , $ args ) ; $ intervals [ ] = $ this -> intervals ; $ output = array ( ) ; $ intervals = call_user_func_array ( 'array_merge' , $ intervals ) ; usort ( $ intervals , array ( $ this... | Variable number of argument of things we re likey to be able to make a set out of . |
55,671 | public function contains ( ) { $ reflection = new \ ReflectionClass ( get_called_class ( ) ) ; $ comparing = $ reflection -> newInstanceArgs ( func_get_args ( ) ) ; if ( ! $ this -> containsNull and $ comparing -> containsNull ) { return false ; } reset ( $ this -> intervals ) ; reset ( $ comparing -> intervals ) ; lis... | Is a set contained within another set |
55,672 | public function invert ( ) { $ this -> containsNull = ! $ this -> containsNull ; if ( $ this -> intervals === array ( array ( null , null ) ) ) { $ this -> intervals = array ( ) ; return $ this ; } $ output = array ( ) ; $ working = array ( null , null ) ; reset ( $ this -> intervals ) ; while ( list ( , $ interval ) =... | Invert a set . |
55,673 | protected function addHelper ( $ data ) { if ( is_array ( $ data ) ) { $ originalSize = count ( $ data ) ; $ data = array_filter ( $ data , '\Bond\is_not_null' ) ; if ( $ originalSize !== count ( $ data ) ) { $ this -> containsNull = true ; } $ argIntervals = array_map ( null , $ data , $ data ) ; $ argIntervals = arra... | Convert something that looks like it s going to be a set castable into a array of intervals Not nessisarily sorted |
55,674 | private function parseStringToIntervals ( $ string ) { if ( ! $ length = mb_strlen ( $ string ) ) { return array ( ) ; } $ intervals = array ( ) ; $ interval = array ( '' ) ; $ c = 0 ; $ isCharEscaped = false ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ char = mb_substr ( $ string , $ i , 1 ) ; if ( $ isCharEscaped ... | Parse the data into an array of unique values |
55,675 | private final function sortIntervals ( $ a , $ b ) { if ( 0 !== $ lowerCompare = $ this -> sort ( $ a [ 0 ] , $ b [ 0 ] , self :: NULL_IS_LOW ) ) { return $ lowerCompare ; } return - $ this -> sort ( $ a [ 1 ] , $ b [ 1 ] , self :: NULL_IS_HIGH ) ; } | Sort two intervals |
55,676 | protected function max ( $ a , $ b , $ handleNull ) { return $ this -> sort ( $ a , $ b , $ handleNull ) > 0 ? $ a : $ b ; } | Return the max of two things |
55,677 | protected function min ( $ a , $ b , $ handleNull ) { return $ this -> sort ( $ a , $ b , $ handleNull ) > 0 ? $ b : $ a ; } | Return the min of two things . |
55,678 | public static function escape ( $ value , $ escapeNull = true ) { if ( $ value === null ) { return $ escapeNull ? self :: ESCAPE_CHARACTER . self :: NULL_CHARACTER : '' ; } $ value = str_replace ( self :: ESCAPE_CHARACTER , self :: ESCAPE_CHARACTER . self :: ESCAPE_CHARACTER , $ value ) ; $ value = str_replace ( self :... | Escape a interval fragments |
55,679 | public function prepare ( ) { $ this -> preparedRoutes = true ; foreach ( $ this -> routers as $ router ) { $ this -> prepareRoutes ( $ router -> routes ) ; } } | prepares reverse routes from added routers . |
55,680 | public static function maps ( array $ mappings , $ key = 'default' ) { self :: $ mappings = array_merge_recursive ( self :: $ mappings , [ $ key => $ mappings ] ) ; } | Register mappings . |
55,681 | public static function getMappings ( $ resource , $ key = 'default' ) { $ resourceName = $ resource ; if ( is_object ( $ resource ) ) { $ resourceName = get_class ( $ resource ) ; } $ mappings = [ ] ; if ( isset ( self :: $ mappers [ $ key ] ) ) { $ mappings = array_merge_recursive ( $ mappings , call_user_func ( self ... | Get mappings for the resource . |
55,682 | public function resolveMapping ( $ resource , $ parameters = [ ] , $ key = 'default' , $ method = null ) { $ resourceName = $ resource ; if ( is_object ( $ resource ) ) { $ resourceName = get_class ( $ resource ) ; } $ mappings = $ this -> getMappings ( $ resourceName , $ key ) ; if ( empty ( $ mappings ) ) { throw new... | Resolve mapping end return result |
55,683 | public function runResolver ( $ resolver , $ parameters = [ ] , $ method = null ) { if ( is_callable ( $ resolver ) ) { return call_user_func_array ( $ resolver , $ parameters ) ; } if ( class_exists ( $ resolver ) ) { $ instance = $ this -> container -> make ( $ resolver , $ parameters ) ; if ( $ instance instanceof C... | Handle and run the resolver |
55,684 | public function getPostFields ( ) { $ this -> validate ( ) ; $ mappedFields = $ this -> getMappedFields ( ) ; $ this -> paymentMethod -> addAdditionalFields ( $ mappedFields ) ; return $ mappedFields ; } | Get the post fields for the requests . |
55,685 | private function createSimple ( ) : Redis { $ redis = new Redis ( ) ; $ redis -> connect ( $ this -> config [ 'host' ] , ( int ) $ this -> config [ 'port' ] ) ; $ redis -> setOption ( Redis :: OPT_READ_TIMEOUT , '-1' ) ; if ( $ this -> config [ 'database' ] ) { $ redis -> select ( $ this -> config [ 'database' ] ) ; } ... | Create single redis . |
55,686 | protected function getAssetsUrl ( $ inputUrl ) { $ assets = $ this -> getService ( 'assets.packages' ) ; $ url = preg_replace ( '/^asset\[(.+)\]$/i' , '$1' , $ inputUrl ) ; if ( $ inputUrl !== $ url ) { return $ assets -> getUrl ( $ this -> baseUrl . $ url ) ; } return $ inputUrl ; } | Get url from config string |
55,687 | public function getSelector ( $ pkey , array $ record ) { if ( $ pkey !== null && ! is_array ( $ pkey ) ) throw new InvalidTypeException ( "Invalid primary key: " . WF :: str ( $ pkey ) ) ; $ is_primary_key = true ; if ( $ pkey === null ) { $ pkey = array ( ) ; foreach ( $ record as $ k => $ v ) $ pkey [ $ k ] = $ this... | Form a condition that matches the record using the values in the provided record . |
55,688 | public function save ( Model $ model ) { $ database = $ model -> getSourceDB ( ) ; $ pkey = $ model -> getID ( ) ; if ( $ database === null || $ database !== $ this -> db ) $ this -> insert ( $ model ) ; else $ this -> update ( $ model ) ; return $ this ; } | Save the current record to the database . |
55,689 | public function getByID ( $ id ) { $ pkey = $ this -> getPrimaryKey ( ) ; if ( $ pkey === null ) throw new DAOException ( "A primary key is required to select a record by ID" ) ; if ( count ( $ pkey ) === 1 && is_scalar ( $ id ) ) foreach ( $ pkey as $ colname => $ def ) $ id = [ $ colname => $ id ] ; $ condition = $ t... | Load the record from the database |
55,690 | public function get ( ... $ args ) { $ record = $ this -> fetchSingle ( $ args ) ; if ( ! $ record ) return null ; $ obj = new $ this -> model_class ; $ obj -> assignRecord ( $ record , $ this -> db ) ; return $ obj ; } | Retrieve a single record based on a provided query |
55,691 | public function getAll ( ... $ args ) { $ pkey = $ this -> getPrimaryKey ( ) ; if ( count ( $ pkey ) === 1 ) { reset ( $ pkey ) ; $ pkey_as_index = key ( $ pkey ) ; } else $ pkey_as_index = false ; $ list = array ( ) ; $ records = $ this -> fetchAll ( $ args ) ; foreach ( $ records as $ record ) { $ obj = new $ this ->... | Retrieve a set of records create object from them and return the resulting list . |
55,692 | public function fetchSingle ( ... $ args ) { $ args [ ] = QB :: limit ( 1 ) ; $ select = $ this -> select ( $ args ) ; return $ select -> fetch ( ) ; } | Execute a query retrieve the first record and return it . |
55,693 | public function select ( ... $ args ) { $ args = WF :: flatten_array ( $ args ) ; $ select = new Query \ Select ; $ select -> add ( new Query \ SourceTableClause ( $ this -> tablename ) ) ; $ cols = $ this -> getColumns ( ) ; foreach ( $ cols as $ name => $ def ) $ select -> add ( new Query \ GetClause ( $ name ) ) ; f... | Select one or more records from the database . |
55,694 | public function update ( $ id , array $ record = null ) { $ model = is_a ( $ id , $ this -> model_class ) ? $ id : null ; if ( null !== $ model ) { if ( $ record !== null ) throw new DAOException ( "You should not pass an array of updates when supplying a Model" ) ; if ( $ id -> getSourceDB ( ) !== $ this -> db ) throw... | Update records in the database . |
55,695 | public function delete ( $ where ) { $ is_model = is_a ( $ where , $ this -> model_class ) ; if ( ! $ is_model && ! is_a ( $ where , Query \ WhereClause :: class ) ) throw new InvalidTypeException ( "Must provide a WhereClause or an instance of {$this->model_class} to delete" ) ; $ modelInstance = null ; if ( $ is_mode... | Delete records from the database . |
55,696 | public function route ( $ name , $ details = [ ] ) { $ this -> route = route ( $ name , $ details ) ; $ this -> routeName = $ name ; return $ this ; } | Add a route to redirect the request to . |
55,697 | public function redirectIntended ( ) { if ( is_null ( $ this -> route ) ) { throw new \ Exception ( 'No route has been provided. Please use route() to add one.' ) ; } if ( $ this -> success ) { return redirect ( ) -> intended ( $ this -> route ) -> with ( 'message' , $ this -> message ) ; } return redirect ( $ this ->... | Redirect the request to the intended route or the provided one . |
55,698 | public function associateRelatedRecordsToNewRecord ( $ modelInstance , $ associatedRecords , $ relatedNamespace , $ relatedModelClass ) { if ( count ( $ associatedRecords ) > 0 ) { $ namespaceModelclass = $ relatedNamespace . "\\" . $ relatedModelClass ; $ relatedRepository = new \ Lasallecms \ Lasallecmsapi \ Reposito... | Associate each related record with the record just created |
55,699 | public function associateRelatedRecordsToUpdatedRecord ( $ modelInstance , $ associatedRecords , $ relatedModelClass ) { if ( count ( $ associatedRecords ) > 0 ) { $ newIds = array ( ) ; foreach ( $ associatedRecords as $ associatedId ) { $ newIds [ ] = $ associatedId ; } $ relatedMethod = strtolower ( $ relatedModelCl... | Associate each related record with the record just updated . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.