idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
231,100 | protected function parse ( $ comment ) { $ this -> description = '' ; $ this -> tags = [ ] ; $ comment = preg_replace ( "'^\s*/*\**'m" , '' , substr ( $ comment , 0 , - 2 ) ) ; $ parts = preg_split ( "'^\s*@([a-zA-Z][a-zA-Z0-9]*)'m" , $ comment , - 1 , PREG_SPLIT_DELIM_CAPTURE ) ; $ this -> description = preg_replace (... | Parse the given doc comment and populate description and tags . |
231,101 | protected function setMessage ( $ message , array $ parameters = [ ] ) { $ message = sprintf ( "%s: %s." , ( new \ ReflectionClass ( $ this ) ) -> getShortName ( ) , $ message ) ; $ parameters = array_map ( [ $ this -> getDumper ( ) , "dump" ] , $ parameters ) ; $ this -> message = call_user_func_array ( "sprintf" , ar... | Sets the error message . |
231,102 | public function addMethod ( $ method , callable $ callback ) { if ( ! is_string ( $ method ) ) { throw new \ InvalidArgumentException ( '$method must be string' ) ; } $ this -> plugins [ $ method ] = $ callback ; } | Dynamically add a method to the class . |
231,103 | public function addSetters ( array $ setters ) { foreach ( $ setters as $ property => $ setter ) { if ( is_int ( $ property ) ) { $ property = $ setter ; $ setter = 'set' . ucfirst ( $ setter ) ; } $ this -> setters [ $ setter ] = $ property ; } } | Register multiple property setters . |
231,104 | public function addManuallyAction ( Request $ request ) { $ response = $ this -> getCacheTimeKeeper ( ) -> getResponse ( ) ; if ( $ response -> isNotModified ( $ request ) ) { return $ response ; } $ item = new Item ( ) ; $ form = $ this -> createForm ( 'entity_item' , $ item ) -> handleRequest ( $ request ) ; if ( $ f... | Addition form . |
231,105 | public function changeAction ( Item $ item , Request $ request ) { $ form = $ this -> createForm ( 'entity_item' , $ item ) -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ item ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ ... | Change item . |
231,106 | public function deleteAction ( Item $ item ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> remove ( $ item ) ; $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'home' ) ) ; } | Delete item . |
231,107 | public function importAction ( $ plugin , Request $ request ) { $ chain = $ this -> get ( 'anime_db.plugin.import' ) ; if ( ! ( $ import = $ chain -> getPlugin ( $ plugin ) ) ) { throw $ this -> createNotFoundException ( 'Plugin \'' . $ plugin . '\' is not found' ) ; } $ form = $ this -> createForm ( $ import -> getFor... | Import items . |
231,108 | public function duplicateAction ( Request $ request ) { $ rep = $ this -> getDoctrine ( ) -> getRepository ( 'AnimeDbCatalogBundle:Item' ) ; $ item = $ request -> getSession ( ) -> get ( self :: NAME_ITEM_ADDED ) ; if ( ! ( $ item instanceof Item ) ) { throw $ this -> createNotFoundException ( 'Not found item for confi... | Confirm duplicate item . |
231,109 | public function limitControlAction ( Request $ request , $ total = '' ) { $ controls = $ this -> get ( 'anime_db.item.list_controls' ) ; if ( ! is_numeric ( $ total ) || $ total < 0 ) { $ rep = $ this -> getDoctrine ( ) -> getRepository ( 'AnimeDbCatalogBundle:Item' ) ; $ total = $ rep -> count ( ) ; } return $ this ->... | List items limit control . |
231,110 | public function sortControlAction ( Request $ request ) { $ controls = $ this -> get ( 'anime_db.item.list_controls' ) ; $ direction = $ controls -> getSortDirection ( $ request -> query -> all ( ) ) ; $ sort_direction = [ 'type' => $ direction == 'ASC' ? 'DESC' : 'ASC' , 'link' => $ controls -> getSortDirectionLink ( ... | List items sort control . |
231,111 | public static function editDocumentLink ( $ path ) { if ( self :: isLoggedIn ( ) ) { $ path = 0 === strpos ( $ path , '/' ) ? substr ( $ path , 1 ) : $ path ; return Request :: $ subfolders . 'cms/documents/edit-document?slug=' . urlencode ( $ path ) ; } else { return '' ; } } | Returns the cms link for editing a document |
231,112 | public static function newDocument ( $ path = '/' , $ documentType = '' ) { if ( self :: isLoggedIn ( ) ) { $ return = self :: getAssetsIfNotIncluded ( ) ; return $ return . '<a title="New Document" data-href="' . self :: newDocumentLink ( $ path , $ documentType ) . '" class="ccEditDocumentButton ccNewDocumentButton">... | Returns a button with a link for creating a new document |
231,113 | public static function newDocumentLink ( $ path = '/' , $ documentType = '' ) { if ( self :: isLoggedIn ( ) ) { $ path = 0 === strpos ( $ path , '/' ) ? $ path : '/' . $ path ; $ linkPostFix = '' ; if ( $ documentType !== '' ) { $ linkPostFix = '&documentType=' . $ documentType ; } return Request :: $ subfolders . ... | Returns the cms link for creating a new document |
231,114 | public function resolveFile ( StorageFacilityParams $ params , $ fileid ) { return new StorageFacilityFile ( $ fileid , $ this -> generateStoragePath ( $ params , $ fileid ) , $ this -> generateUrl ( $ params , $ fileid ) ) ; } | Using storage facility params generate a StorageFacilityFile object without querying storage |
231,115 | protected function createProcessBuilder ( array $ arguments = [ ] , $ timeout = null ) : ProcessBuilder { $ pb = new ProcessBuilder ( $ arguments ) ; if ( null !== $ timeout ) { $ pb -> setTimeout ( $ timeout ) ; } return $ pb ; } | Creates a new process builder that your might use to interact with your virus - scanner s executable . |
231,116 | public function getUserProfile ( ) { if ( $ this -> _userProfile == NULL ) $ this -> _userProfile = $ this -> getAdapter ( ) -> getUserProfile ( ) ; return $ this -> _userProfile ; } | Caches the getUserProfile request to prevent rate limiting issues . |
231,117 | public function setProvider ( $ provider = NULL ) { if ( $ provider == NULL ) throw new CException ( Yii :: t ( 'Hybridauth.main' , "You haven't supplied a provider" ) ) ; $ this -> _provider = $ provider ; return $ this -> _provider ; } | Sets the provider for this controller to use |
231,118 | private function hybridAuth ( ) { if ( strtolower ( $ this -> getProvider ( ) ) == 'openid' ) { if ( ! isset ( $ _GET [ 'openid-identity' ] ) ) throw new CException ( Yii :: t ( 'Hybridauth.main' , "You chose OpenID but didn't provide an OpenID identifier" ) ) ; else $ params = array ( "openid_identifier" => $ _GET [ '... | Handles authenticating the user against the remote identity |
231,119 | private function authenticate ( ) { $ form = new RemoteIdentityForm ; $ form -> attributes = array ( 'adapter' => $ this -> getUserProfile ( ) , 'provider' => $ this -> getProvider ( ) ) ; return $ form -> login ( ) ; } | Authenticates in as the user |
231,120 | private function renderLinkForm ( ) { $ this -> layout = '//layouts/main' ; $ this -> setPageTitle ( Yii :: t ( 'HybridAuth.main' , '{{app_name}} | {{label}}' , array ( '{{app_name}}' => Cii :: getConfig ( 'name' , Yii :: app ( ) -> name ) , '{{label}}' => Yii :: t ( 'HybridAuth.main' , 'Link Your Account' ) ) ) ) ; $ ... | Renders the linking form |
231,121 | protected function getGroup ( string $ name ) : array { if ( ! $ this -> container -> has ( 'config_' . $ name ) ) { $ this -> loadGroup ( $ name ) ; } return $ this -> container -> get ( 'config_' . $ name ) ; } | Loads a group configuration file it has not been loaded before and returns its options . If the group doesn t exist creates an empty one . |
231,122 | protected function loadGroup ( string $ name ) : void { $ file = $ this -> container -> get ( 'config_dir' ) . '/' . $ name . '.php' ; $ data = \ is_file ( $ file ) ? include ( $ file ) : [ ] ; $ this -> container [ 'config_' . $ name ] = $ data ; } | Load group from file by group name . |
231,123 | protected function get ( $ name ) { return isset ( $ this -> disks [ $ name ] ) ? $ this -> disks [ $ name ] : $ this -> resolve ( $ name ) ; } | Attempt to get the disk from the local cache . |
231,124 | public function load ( array $ configs , ContainerBuilder $ container ) { $ config = $ this -> processConfiguration ( new Configuration ( ) , $ configs ) ; if ( empty ( $ config [ 'theme' ] ) ) { $ config [ 'theme' ] = array ( 'simple' => array ( ) , ) ; } else { foreach ( $ config [ 'theme' ] as & $ bundleTheme ) { if... | Loads the ZichtTinymce configuration . |
231,125 | protected function fetchCollection ( Select $ select ) { $ collection = [ ] ; foreach ( $ this -> selectWith ( $ select ) as $ entity ) { $ collection [ $ entity -> getIdentifier ( ) ] = $ entity ; } return $ collection ; } | Fetch array collection of entities |
231,126 | public function insertEntity ( EntityInterface $ entity ) { $ insert = $ this -> getSql ( ) -> insert ( ) ; $ insert -> values ( $ this -> getHydrator ( ) -> extract ( $ entity ) ) ; try { $ this -> insertWith ( $ insert ) ; } catch ( RuntimeException $ e ) { return false ; } return true ; } | Insert an new entity |
231,127 | public function updateEntity ( EntityInterface $ entity ) { $ update = $ this -> getSql ( ) -> update ( ) ; $ update -> set ( $ this -> getHydrator ( ) -> extract ( $ entity ) ) ; $ update -> where -> equalTo ( $ this -> getPrimaryKey ( ) , $ entity -> getIdentifier ( ) ) ; try { $ this -> updateWith ( $ update ) ; } c... | Update an existing entity |
231,128 | private function UpdateBundleVersions ( ) { $ this -> ClearInstalledBundles ( ) ; $ bundles = PathUtil :: Bundles ( ) ; foreach ( $ bundles as $ bundle ) { if ( ! array_key_exists ( $ bundle , $ this -> failedBundles ) ) { $ this -> UpdateBundleVersion ( $ bundle ) ; } } } | Updates database to store current bundle versions |
231,129 | private function UpdateBundleVersion ( $ bundle ) { $ instBundle = InstalledBundle :: Schema ( ) -> ByBundle ( $ bundle ) ; if ( ! $ instBundle ) { $ instBundle = new InstalledBundle ( ) ; } $ instBundle -> SetVersion ( $ this -> installedBundles [ $ bundle ] ) ; $ instBundle -> SetBundle ( $ bundle ) ; $ instBundle ->... | Updates the version of the bundle |
231,130 | private function ClearInstalledBundles ( ) { $ bundles = PathUtil :: Bundles ( ) ; $ sql = new Sql \ Builder ( $ this -> connection ) ; $ inList = $ sql -> InListFromValues ( $ bundles ) ; $ tbl = InstalledBundle :: Schema ( ) -> Table ( ) ; $ where = $ sql -> NotIn ( $ tbl -> Field ( 'Bundle' ) , $ inList ) ; Installe... | Clears installed bundles |
231,131 | private function InstallBundle ( $ bundle ) { $ manifest = ClassFinder :: Manifest ( $ bundle ) ; foreach ( $ manifest -> Dependencies ( ) as $ dependency ) { if ( ! $ this -> InstallDependency ( $ dependency ) ) { return false ; } } $ bundleInstaller = new BundleInstaller ( $ manifest , $ this -> connection , $ this -... | Installs a single bundle |
231,132 | private function InstallDependency ( BundleDependency $ dependency ) { $ bundle = $ dependency -> BundleName ( ) ; if ( array_key_exists ( $ bundle , $ this -> failedBundles ) ) { return false ; } $ installedVersion = $ this -> InstalledVersion ( $ bundle ) ; $ manifest = ClassFinder :: Manifest ( $ bundle ) ; if ( ! $... | Installs a dependency |
231,133 | protected function getModuleOutput ( $ module ) { $ console = $ this -> console ; $ head = sprintf ( "%s\n%s\n%s\n" , str_repeat ( '-' , $ console -> getWidth ( ) ) , 'Testing Module: ' . $ module , str_repeat ( '-' , $ console -> getWidth ( ) ) ) ; return $ console -> colorize ( $ head , ColorInterface :: BLUE ) ; } | Get module output |
231,134 | protected function renderTable ( $ data , $ cols , $ consoleWidth ) { $ result = '' ; $ padding = 2 ; if ( $ cols == 1 ) { foreach ( $ data as $ row ) { $ result .= $ row [ 0 ] . "\n" ; } return $ result ; } $ strWrapper = StringUtils :: getWrapper ( 'UTF-8' ) ; $ maxW = array ( ) ; for ( $ x = 1 ; $ x <= $ cols ; $ x ... | Render a text table containing the data provided that will fit inside console window s width . |
231,135 | public function copy ( ) { $ angle = new Angle ( ) ; $ angle -> radians = $ this -> radians ; $ angle -> sin = $ this -> sin ; $ angle -> cos = $ this -> cos ; $ angle -> tan = $ this -> tan ; return $ angle ; } | Returns a copy of the current angle . |
231,136 | public function set ( $ radians ) { $ this -> radians = $ radians ; $ this -> sin = sin ( $ radians ) ; $ this -> cos = cos ( $ radians ) ; $ this -> tan = tan ( $ radians ) ; return $ this ; } | Resets the angle in radians . |
231,137 | public function onFlush ( OnFlushEventArgs $ eventArgs ) { $ this -> eventQueue -> setOpened ( true ) ; $ uow = $ eventArgs -> getEntityManager ( ) -> getUnitOfWork ( ) ; foreach ( $ uow -> getScheduledEntityInsertions ( ) as $ entity ) { if ( $ entity instanceof ResourceInterface ) { $ this -> eventQueue -> scheduleIn... | On flush event handler . |
231,138 | public static function find ( array $ query ) { if ( isset ( $ query [ 'semester' ] ) && $ query [ 'semester' ] instanceof Semester ) { $ query [ 'semester' ] = $ query [ 'semester' ] -> daisyFormat ( ) ; } $ csis = Client :: get ( "courseSegment" , $ query ) ; return array_map ( function ( $ data ) { return new self (... | Retrieve an array of CourseSegmentInstance objects according to a search query . |
231,139 | protected function addUniqueRuleException ( array $ rules , $ id ) { foreach ( $ rules as $ key => & $ rule ) { if ( is_array ( $ rule ) ) { $ rule = $ this -> addUniqueRuleException ( $ rule , $ id ) ; continue ; } $ unique_pos = strpos ( $ rule , 'unique:' ) ; if ( $ unique_pos !== false ) { $ next_rule_pos = strpos ... | Add exception to any unique rules for given object id |
231,140 | public function newValidator ( array & $ params , array $ rules , $ clean = true ) { if ( ! empty ( $ params [ 'id' ] ) ) { $ rules = $ this -> addUniqueRuleException ( $ rules , $ params [ 'id' ] ) ; } if ( $ clean ) { $ params = $ this -> cleanParams ( $ params , $ rules ) ; } return ValidatorFacade :: make ( $ param... | Set new validator instance |
231,141 | private function getBody ( ) { if ( $ this -> body ) { return $ this -> body ; } elseif ( $ this -> files || $ this -> forceMultipart ) { return $ this -> body = $ this -> createMultipart ( ) ; } elseif ( $ this -> fields ) { return $ this -> body = $ this -> createUrlEncoded ( ) ; } else { return $ this -> body = Stre... | Return a stream object that is built from the POST fields and files . |
231,142 | public function generate ( $ till = self :: UNTIL_FRAGMENT ) { $ url = null !== $ this -> getScheme ( ) ? $ this -> getScheme ( ) . '://' : '' ; if ( $ till !== self :: UNTIL_SCHEME ) { $ url .= null !== $ this -> getUser ( ) ? $ this -> getUser ( ) . ':' : '' ; if ( $ till !== self :: UNTIL_USER ) { $ url .= null !== ... | Adds all the components of the url until the end or until the first parameter has been reached to generate a URL |
231,143 | private function pdoPrepare ( $ sql ) { try { $ pdoStatement = $ this -> getPdo ( ) -> prepare ( $ sql ) ; } catch ( \ PDOException $ e ) { throw new \ RuntimeException ( "Failed to prepare SQL query: {$sql} << {$e->getMessage()}" , 0 , $ e ) ; } return $ pdoStatement ; } | Prepares a PDO statement . |
231,144 | public function escapeAndQuote ( $ value ) { if ( null === $ value ) { $ pdoType = \ PDO :: PARAM_NULL ; } else { $ pdoType = \ PDO :: PARAM_STR ; } return $ this -> getPdo ( ) -> quote ( $ value , $ pdoType ) ; } | Escapes and quotes provided scalar value . |
231,145 | public function getPdo ( ) { if ( ! $ this -> pdo ) { $ this -> connect ( ) ; } $ this -> pdo -> setAttribute ( \ PDO :: ATTR_ERRMODE , \ PDO :: ERRMODE_EXCEPTION ) ; $ this -> pdo -> setAttribute ( \ PDO :: ATTR_DEFAULT_FETCH_MODE , \ PDO :: FETCH_ASSOC ) ; return $ this -> pdo ; } | Returns the wrapped PDO object . |
231,146 | private function connect ( ) { $ dsn = "{$this->credentials->getDriver()}:host={$this->credentials->getHost()}" ; try { $ pdo = new \ PDO ( $ dsn , $ this -> credentials -> getUsername ( ) , $ this -> credentials -> getPassword ( ) ) ; } catch ( \ PDOException $ e ) { throw new \ RuntimeException ( 'Failed to connect t... | Attempts to connect to database . |
231,147 | public function unsetSessionUser ( $ sessionKey = NULL ) { $ sessionKey = $ sessionKey ? : SessionUser :: DEFAULT_KEY_NAME ; $ user = Session :: getSessionDataBag ( ) -> get ( $ sessionKey ) ; if ( $ user ) { if ( ! $ user instanceof SessionUser ) { throw new UserException ( sprintf ( "Session key '%s' doesn't hold a S... | remove session user from session returns the removed session user |
231,148 | public function getSessionUser ( $ sessionKey = NULL ) { $ sessionKey = $ sessionKey ? : SessionUser :: DEFAULT_KEY_NAME ; $ sessionUser = Session :: getSessionDataBag ( ) -> get ( $ sessionKey ) ; if ( $ sessionUser instanceof SessionUser ) { return $ sessionUser ; } } | retrieve a stored session user stored under a session key returns stored value only when it is a SessionUser instance |
231,149 | public function elementsOverview ( array $ list , array $ options = [ ] ) { $ options = array_replace ( [ "includeNavigation" => true ] , $ options ) ; $ options [ "inElementsOverview" ] = true ; $ elements = array_map ( function ( $ reference ) { return new Element ( $ reference ) ; } , $ list ) ; return $ this -> app... | Renders a overview of the given elements |
231,150 | public function get ( $ key , $ default = null , $ package = null ) { if ( $ package ) { return $ this -> getForPackage ( $ package , $ key , $ default ) ; } return Arr :: get ( $ this -> mainConfiguration , $ key , $ default ) ; } | Return value stored under provided key |
231,151 | public function getForPackage ( $ package , $ key , $ default = null ) { if ( empty ( $ this -> packagesConfiguration [ $ package ] ) ) { return $ default ; } return Arr :: get ( $ this -> packagesConfiguration [ $ package ] , $ key , $ default ) ; } | Return value stored under provided key for given package |
231,152 | public function set ( $ key , $ value , $ package = null ) { if ( ! is_null ( $ package ) ) { $ this -> setForPackage ( $ package , $ key , $ value ) ; return $ this ; } $ mainConfiguration = $ this -> mainConfiguration ; Arr :: set ( $ mainConfiguration , $ key , $ value ) ; return $ this ; } | Store given value under given key |
231,153 | public function setForPackage ( $ package , $ key , $ value ) { $ packageConfiguration = empty ( $ this -> packagesConfiguration [ $ package ] ) ? array ( ) : $ this -> packagesConfiguration [ $ package ] ; Arr :: set ( $ packageConfiguration , $ key , $ value ) ; $ this -> packagesConfiguration [ $ package ] = $ packa... | Store given value under given key for given package |
231,154 | public function findFile ( $ filePath ) { if ( file_exists ( $ filePath ) ) { return $ filePath ; } foreach ( $ this -> supportedExtensions as $ extension ) { $ extendedFilePath = $ filePath . '.' . $ extension ; if ( file_exists ( $ extendedFilePath ) ) { return $ extendedFilePath ; } $ extendedFilePath = $ filePath .... | Tries to find existing file with supported extension |
231,155 | private function processFile ( $ filePath , $ group = null , $ baseDir = null ) { if ( is_null ( $ baseDir ) ) { $ baseDir = $ this -> baseDirectory ; } if ( ! is_string ( $ baseDir ) ) { $ baseDir = '' ; } if ( $ baseDir ) { $ baseDir = rtrim ( $ baseDir , '/' ) . '/' ; } $ content = $ this -> findAndParseFile ( $ bas... | Processing the file optionally putting result under group |
231,156 | private function extractFileNameBase ( $ filePath ) { $ directories = explode ( '/' , $ filePath ) ; $ fileName = array_pop ( $ directories ) ; $ fileNameParts = explode ( '.' , $ fileName ) ; if ( count ( $ fileNameParts ) > 1 ) { $ extension = array_pop ( $ fileNameParts ) ; } $ result = implode ( '.' , $ fileNamePar... | Return file name base without directories and without extension |
231,157 | private function assembleEnvironmentFilePath ( $ filePath , $ environment = true ) { if ( true === $ environment ) { $ environment = $ this -> environmentInstance -> getEnvironment ( ) ; } $ directories = explode ( '/' , $ filePath ) ; $ fileName = array_pop ( $ directories ) ; $ fileNameWithoutExtension = $ this -> ex... | Assemble path to configuration file with environment taken into account |
231,158 | protected function getDesiredImageQuality ( $ ext , $ format ) { switch ( $ ext ) { case 'jpeg' : case 'jpg' : $ qualityConfig = $ this -> jpegQuality ; break ; case 'png' : $ qualityConfig = $ this -> pngQuality ; break ; default : $ qualityConfig = null ; } if ( empty ( $ qualityConfig ) ) { return null ; } if ( is_a... | Figure out image quality . |
231,159 | public function index ( ) { $ this -> authorize ( RedirectsPolicy :: PERMISSION_LIST ) ; $ redirects = Redirect :: query ( ) -> paginate ( 50 ) ; $ this -> setTitle ( $ title = trans ( 'seo::redirects.titles.redirections-list' ) ) ; $ this -> addBreadcrumb ( $ title ) ; return $ this -> view ( 'admin.redirects.index' ,... | Get the index page . |
231,160 | public function create ( ) { $ this -> authorize ( RedirectsPolicy :: PERMISSION_CREATE ) ; $ statuses = RedirectStatuses :: all ( ) ; $ this -> setTitle ( $ title = trans ( 'seo::redirects.titles.create-redirection' ) ) ; $ this -> addBreadcrumb ( $ title ) ; return $ this -> view ( 'admin.redirects.create' , compact ... | Get the create form . |
231,161 | public function store ( CreateRedirectRequest $ request ) { $ this -> authorize ( RedirectsPolicy :: PERMISSION_CREATE ) ; $ redirect = Redirect :: createRedirect ( $ request -> getValidatedData ( ) ) ; $ this -> transNotification ( 'created' , [ ] , $ redirect -> toArray ( ) ) ; return redirect ( ) -> route ( 'admin::... | Store the new redirect . |
231,162 | public function show ( Redirect $ redirect ) { $ this -> authorize ( RedirectsPolicy :: PERMISSION_SHOW ) ; $ this -> setTitle ( $ title = trans ( 'seo::redirects.titles.redirection-details' ) ) ; $ this -> addBreadcrumb ( $ title ) ; return $ this -> view ( 'admin.redirects.show' , compact ( 'redirect' ) ) ; } | Show the redirect details page . |
231,163 | public function edit ( Redirect $ redirect ) { $ this -> authorize ( RedirectsPolicy :: PERMISSION_UPDATE ) ; $ statuses = RedirectStatuses :: all ( ) ; $ this -> setTitle ( $ title = trans ( 'seo::redirects.titles.edit-redirection' ) ) ; $ this -> addBreadcrumb ( $ title ) ; return $ this -> view ( 'admin.redirects.ed... | Get the edit page . |
231,164 | public function update ( Redirect $ redirect , UpdateRedirectRequest $ request ) { $ this -> authorize ( RedirectsPolicy :: PERMISSION_UPDATE ) ; $ redirect -> update ( $ request -> getValidatedData ( ) ) ; $ this -> transNotification ( 'updated' , [ ] , $ redirect -> toArray ( ) ) ; return redirect ( ) -> route ( 'adm... | Update the redirect . |
231,165 | public function delete ( Redirect $ redirect ) { $ this -> authorize ( RedirectsPolicy :: PERMISSION_DELETE ) ; $ redirect -> delete ( ) ; return $ this -> jsonResponseSuccess ( [ 'message' => $ this -> transNotification ( 'deleted' , [ ] , $ redirect -> toArray ( ) ) ] ) ; } | Delete a redirect record . |
231,166 | protected function transNotification ( $ action , array $ replace = [ ] , array $ context = [ ] ) { $ title = trans ( "seo::redirects.messages.{$action}.title" ) ; $ message = trans ( "seo::redirects.messages.{$action}.message" , $ replace ) ; Log :: info ( $ message , $ context ) ; $ this -> notifySuccess ( $ message ... | Notify with translation . |
231,167 | public static function generate ( $ contact , $ options = array ( ) ) { if ( ! isset ( Lightrail :: $ apiKey ) || empty ( Lightrail :: $ apiKey ) ) { throw new Exceptions \ BadParameterException ( "Lightrail.apiKey is empty or not set." ) ; } if ( ! isset ( Lightrail :: $ sharedSecret ) || empty ( Lightrail :: $ shared... | Generate a shopper token that can be used to make Lightrail calls restricted to that particular shopper . The shopper can be defined by the contactId userSuppliedId or shopperId . |
231,168 | private function prepareServices ( ) { $ services = new Container ; $ services -> set ( Router :: class , new Router , true ) ; $ services -> set ( Dispatcher :: class , new Dispatcher , true ) ; $ services -> set ( PackageManager :: class , new PackageManager , true ) ; $ services -> set ( EventManager :: class , new ... | Prepares services required by Tonis . We ll put them in the DIC so that they re available to other factories if necessary . |
231,169 | public function format ( Address $ address ) { $ fields = [ 'p-street-address' => $ address -> getStreet ( ) , 'p-extended-address' => $ address -> getExtended ( ) , 'p-post-office-box' => $ address -> getPobox ( ) , 'p-locality' => $ address -> getLocality ( ) , 'p-region' => $ address -> getRegion ( ) , 'p-postal-cod... | Formats an address . |
231,170 | function addMilliseconds ( $ milliseconds ) { if ( ! is_int ( $ milliseconds ) ) return false ; if ( $ milliseconds == 0 ) return true ; $ millisecond = $ this -> millisecond + $ milliseconds ; $ milliseconds = $ millisecond % 1000 ; if ( $ milliseconds < 0 ) { $ milliseconds += 1000 ; } $ seconds = ( int ) ( ( $ milli... | public instance methods |
231,171 | function dayOfWeek ( ) { $ num = func_num_args ( ) ; if ( $ num == 3 ) { $ args = func_get_args ( ) ; $ y = $ args [ 0 ] ; $ m = $ args [ 1 ] ; $ d = $ args [ 2 ] ; } else { $ y = $ this -> year ; $ m = $ this -> month ; $ d = $ this -> day ; } $ d += $ m < 3 ? $ y -- : $ y - 2 ; return ( ( int ) ( 23 * $ m / 9 ) + $ d... | public instance & static methods |
231,172 | protected function callFactoryMethod ( $ typeName , $ factory , $ methodName , array $ resolvers = NULL , InjectionPointInterface $ point = NULL ) { $ ref = new \ ReflectionMethod ( get_class ( $ factory ) , $ methodName ) ; foreach ( $ ref -> getParameters ( ) as $ param ) { if ( Configuration :: class === $ this -> g... | Create an object instance by calling a factory method on an object . |
231,173 | protected function reviveMarker ( $ typeName , array $ params = NULL ) { static $ refs = [ ] ; if ( empty ( $ refs [ $ typeName ] ) ) { $ refs [ $ typeName ] = new \ ReflectionClass ( $ typeName ) ; } $ marker = $ refs [ $ typeName ] -> newInstanceWithoutConstructor ( ) ; foreach ( ( array ) $ params as $ k => $ v ) { ... | Revives a marker instance by creating it without constructor invocation . |
231,174 | public function createFromImportedData ( $ name , $ data ) { if ( ! is_array ( $ data ) ) { return new GroupParameter ( $ name , [ $ data ] ) ; } elseif ( ! $ this -> isAssociativeArray ( $ data ) ) { return new GroupParameter ( $ name , $ data ) ; } $ parameter = new GroupParameter ( $ name ) ; foreach ( $ data as $ c... | Create GroupParameter instance from imported data . |
231,175 | public function createRequiredFromTemplates ( $ templates ) { $ parameters = [ ] ; if ( ! empty ( $ templates ) ) { foreach ( $ templates as $ template ) { if ( $ template -> required ) { $ parameters [ ] = $ this -> createFromTemplate ( $ template ) ; } } } return $ parameters ; } | Create GroupParameter instances from all given required templates . |
231,176 | public function createFromTemplate ( $ template ) { $ parameter = new GroupParameter ( ) ; $ parameter -> setName ( $ template -> name ) ; $ parameter -> setTemplate ( $ template ) ; if ( $ template -> type == GroupParameterType :: HASHTABLE && isset ( $ template -> entries ) ) { $ parameter -> setChildren ( $ this -> ... | Create GroupParameter instance from given template . |
231,177 | protected function setRootDir ( $ rootDir ) { if ( ! is_string ( $ rootDir ) || ! is_dir ( $ rootDir ) || ! is_readable ( $ rootDir ) ) { throw new InvalidArgumentException ( Message :: get ( Message :: CONFIG_DIR_INVALID , $ rootDir ) , Message :: CONFIG_DIR_INVALID ) ; } $ this -> root_dir = rtrim ( $ rootDir , '/\\'... | Set root directory |
231,178 | public function addToken ( $ token ) { if ( ! in_array ( $ token , $ this -> tokens ) ) { $ this -> tokens [ ] = $ token ; } return $ this ; } | Add a token device . |
231,179 | function TopMost ( ) { $ sql = Access :: SqlBuilder ( ) ; $ tbl = PageContent :: Schema ( ) -> Table ( ) ; $ where = $ sql -> Equals ( $ tbl -> Field ( 'Page' ) , $ sql -> Value ( $ this -> page -> GetID ( ) ) ) -> And_ ( $ sql -> Equals ( $ tbl -> Field ( 'Area' ) , $ sql -> Value ( $ this -> area -> GetID ( ) ) ) ) -... | Returns the root and first content element in a page and area |
231,180 | public function setCredentials ( $ credentials ) { if ( function_exists ( 'env' ) ) { $ host = env ( 'DB_HOST' ) ; $ dbname = env ( 'DB_DATABASE' ) ; $ username = env ( 'DB_USERNAME' ) ; $ password = env ( 'DB_PASSWORD' ) ; } else { $ host = $ credentials [ 'host' ] ; $ dbname = $ credentials [ 'dbname' ] ; $ username ... | Set the credentials to connect with mysql |
231,181 | public function setTitles ( $ titles ) { $ titles = is_array ( $ titles ) ? $ titles : func_get_args ( ) ; if ( count ( $ titles ) > 0 ) { $ this -> titles = '"' . implode ( '", "' , $ titles ) . '"' ; } } | Set the titles for the csv |
231,182 | public function setColumns ( $ columns ) { $ columns = is_array ( $ columns ) ? $ columns : func_get_args ( ) ; if ( count ( $ columns ) > 0 ) { $ this -> columns = implode ( ', ' , $ columns ) ; } } | Set the columns to export |
231,183 | public function join ( $ table , $ key_one , $ operator , $ key_two = null ) { if ( is_null ( $ key_two ) ) { $ key_two = $ operator ; $ operator = '=' ; } $ this -> joins .= " JOIN {$table} ON {$key_one} {$operator} {$key_two} " ; return $ this ; } | Add a join to the query |
231,184 | public function where ( $ field , $ value , $ not = false ) { $ reserverd_word = $ this -> with_where ? 'AND' : 'WHERE' ; $ operator = $ not ? '!=' : '=' ; $ this -> query .= "{$reserverd_word} {$field} {$operator} '{$value}'" ; $ this -> with_where = true ; return $ this ; } | Add a condition to the initial query |
231,185 | public function execute ( ) { $ this -> columns = $ this -> columns ? : '*' ; $ query = "SELECT {$this->columns} FROM $this->table " ; if ( $ this -> joins ) { $ query .= $ this -> joins ; } $ query .= $ this -> query ; if ( is_null ( $ this -> filename ) ) { $ this -> filename = '/tmp/file.csv' ; } $ query .= " ... | Function for generate csv and return the filename |
231,186 | public function dispatch ( Request $ request ) { $ resourceParts = explode ( '/' , $ request -> getResource ( ) ) ; $ resourceName = $ resourceParts [ 0 ] ; $ subResourceName = false ; if ( count ( $ resourceParts ) > 1 ) { $ subResourceName = $ resourceParts [ 1 ] ; } try { $ resourceMetadata = $ this -> resourceMetad... | Processes a REST request returning a Response object . |
231,187 | protected function registerListeners ( $ service ) { $ serviceMetadata = $ this -> serviceMetadataFactory -> getMetadataFor ( get_class ( $ service ) ) ; foreach ( $ serviceMetadata -> getAllListeners ( ) as $ event => $ listeners ) { foreach ( $ listeners as $ listener ) { $ this -> eventManager -> addListener ( $ eve... | Registers listeners for the supplied service instance . Listeners are obtained from ServiceMetadata for the class of the instance . |
231,188 | private function getUsersPermissions ( ) { return [ [ 'name' => 'Users - List all users' , 'description' => 'Allow to list all users.' , 'slug' => UsersPolicy :: PERMISSION_LIST , ] , [ 'name' => 'Users - View a user' , 'description' => 'Allow to view a user\'s details.' , 'slug' => UsersPolicy :: PERMISSION_SHOW , ] ,... | Get user s permissions seeds . |
231,189 | private function getRolesPermissions ( ) { return [ [ 'name' => 'Roles - List all roles' , 'description' => 'Allow to list all roles.' , 'slug' => RolesPolicy :: PERMISSION_LIST , ] , [ 'name' => 'Roles - View a role' , 'description' => 'Allow to view the role\'s details.' , 'slug' => RolesPolicy :: PERMISSION_SHOW , ]... | Get role s permissions seeds . |
231,190 | public static function getRouteByName ( string $ name ) : Route { foreach ( static :: $ routes as $ routes ) { foreach ( $ routes as $ route ) { if ( $ route -> getName ( ) === $ name ) { return $ route ; } } } return null ; } | Tries to fetch a route by name returns null if it doesn t exist |
231,191 | public function getAlias ( $ abstract ) { if ( ! isset ( $ this -> aliases [ $ abstract ] ) ) { return $ abstract ; } if ( $ this -> aliases [ $ abstract ] === $ abstract ) { throw new LogicException ( "[{$abstract}] is aliased to itself." ) ; } return $ this -> getAlias ( $ this -> aliases [ $ abstract ] ) ; } | Get the alias for an abstract if available . |
231,192 | private function initServer ( ) { $ this -> http = new Object ( ) ; $ this -> server = new Object ( ) ; foreach ( $ _SERVER as $ key => $ val ) { $ key = str_replace ( 'request_' , '' , strtolower ( $ key ) ) ; if ( substr ( $ key , 0 , 5 ) === 'http_' ) { $ this -> http -> { Util :: _toCamel ( substr ( $ key , 5 ) ) }... | initializes server values |
231,193 | public function isAjax ( ) { return ( isset ( $ this -> http -> xRequestedWith ) && $ this -> http -> xRequestedWith = 'XMLHttpRequest' || isset ( $ this -> http -> requestedWith ) && $ this -> http -> requestedWith = 'XMLHttpRequest' ) ; } | Checks if the request is an ajax |
231,194 | public static function getInstance ( $ id = 'default' ) { if ( ! isset ( static :: $ instances [ $ id ] ) ) { static :: $ instances [ $ id ] = new self ( ) ; } return static :: $ instances [ $ id ] ; } | If identifier exists it will be return instance if not new instance will create . |
231,195 | public function path ( $ path ) { $ path = strtolower ( trim ( $ path ) ) ; $ first = substr ( $ path , 0 , 1 ) ; if ( $ first == '@' && isset ( $ this -> aliases [ $ path ] ) ) { $ path = $ this -> aliases [ $ path ] ; } elseif ( $ first == '/' ) { $ path = preg_replace ( '/\\//' , $ this -> root ( ) . '/' , $ path , ... | Translate path alias into a actual path or build path . Return absolute path . |
231,196 | public static function toCamelcase ( $ string , $ capitalizeFirstCharacter = false ) { if ( false === is_string ( $ string ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ string ) ) , E_USER_ERROR ) ; } if ( false === is_bool ( $ capit... | Converts string underscores to camelCase |
231,197 | public static function toSnakecase ( $ string ) { if ( false === is_string ( $ string ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string, "%s" given' , __METHOD__ , gettype ( $ string ) ) , E_USER_ERROR ) ; } return ltrim ( strtolower ( preg_replace ( '/[A-Z]([A-Z](?![a-z]))*/'... | Converts string camelcase to snakecase |
231,198 | protected function resolveValue ( $ name , & $ source = null , $ sanitize = true , $ array = false ) { $ result = $ array ? array ( ) : null ; if ( empty ( $ name ) ) { $ result = $ source ; } elseif ( isset ( $ source [ $ name ] ) ) { $ result = $ source [ $ name ] ; } if ( ! $ sanitize ) { return $ result ; } if ( is... | Resolve a value from the given collection . |
231,199 | public function setRequestOrder ( $ requestOrder ) { if ( ! is_string ( $ requestOrder ) ) { throw new InvalidArgumentException ( 'Expected requestOrder to be a string' ) ; } if ( empty ( $ requestOrder ) ) { throw new InvalidArgumentException ( 'An empty string is not a valid requestOrder value' ) ; } $ this -> reques... | Set the request order . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.