idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
2,700
public function linkTopology ( $ devices = null ) { if ( $ devices == null ) $ devices = $ this -> crawl ( ) ; $ links = array ( ) ; foreach ( $ devices as $ feDevice => $ feNeighbours ) { foreach ( $ feNeighbours as $ fe2Device => $ fe2Links ) { foreach ( $ fe2Links as $ fe2Link ) { if ( isset ( $ links [ $ fe2Device ...
Find the layer 2 topology as an array with no link mentioned more than once .
2,701
public static function camelToUnderscore ( $ s ) { $ s = preg_replace ( '#(.)(?=[A-Z])#' , '$1_' , $ s ) ; $ s = strtolower ( $ s ) ; $ s = rawurlencode ( $ s ) ; return $ s ; }
camelCase - > camel_case
2,702
public static function underscoreToCamel ( $ s ) { $ s = preg_replace ( '#_(?=[a-zA-Z])#' , ' ' , $ s ) ; $ s = substr ( ucwords ( 'x' . $ s ) , 1 ) ; $ s = str_replace ( ' ' , '' , $ s ) ; return $ s ; }
camel_case - > camelCase
2,703
protected function o_fontEncoding ( $ id , $ action , $ options = '' ) { if ( $ action !== 'new' ) { $ o = & $ this -> objects [ $ id ] ; } switch ( $ action ) { case 'new' : $ this -> objects [ $ id ] = array ( 't' => 'fontEncoding' , 'info' => $ options ) ; break ; case 'out' : $ res = "\n$id 0 obj\n<< /Type /Encodin...
the font encoding
2,704
protected function o_fontGIDtoCIDMap ( $ id , $ action , $ options = '' ) { if ( $ action !== 'new' ) { $ o = & $ this -> objects [ $ id ] ; } switch ( $ action ) { case 'new' : $ this -> objects [ $ id ] = array ( 't' => 'fontGIDtoCIDMap' , 'info' => $ options ) ; break ; case 'out' : $ res = "\n$id 0 obj\n" ; $ fontF...
a font glyph to character map needed for unicode fonts
2,705
protected function o_annotation ( $ id , $ action , $ options = '' ) { if ( $ action !== 'new' ) { $ o = & $ this -> objects [ $ id ] ; } switch ( $ action ) { case 'new' : $ pageId = $ this -> currentPage ; $ this -> o_page ( $ pageId , 'annot' , $ id ) ; switch ( $ options [ 'type' ] ) { case 'link' : $ this -> objec...
an annotation object this will add an annotation to the current page . initially will support just link annotations
2,706
protected function o_extGState ( $ id , $ action , $ options = "" ) { static $ valid_params = array ( "LW" , "LC" , "LC" , "LJ" , "ML" , "D" , "RI" , "OP" , "op" , "OPM" , "Font" , "BG" , "BG2" , "UCR" , "TR" , "TR2" , "HT" , "FL" , "SM" , "SA" , "BM" , "SMask" , "CA" , "ca" , "AIS" , "TK" ) ; if ( $ action !== "new" )...
graphics state object
2,707
function setCurrentFont ( ) { $ this -> currentFont = $ this -> currentBaseFont ; $ this -> currentFontNum = $ this -> fonts [ $ this -> currentFont ] [ 'fontNum' ] ; }
sets up the current font based on the font families and the current text state note that this system is quite flexible a bold - italic font can be completely different to a italic - bold font and even bold - bold will have to be defined within the family to have meaning This function is to be called whenever the curren...
2,708
function setLineTransparency ( $ mode , $ opacity ) { static $ blend_modes = array ( "Normal" , "Multiply" , "Screen" , "Overlay" , "Darken" , "Lighten" , "ColorDogde" , "ColorBurn" , "HardLight" , "SoftLight" , "Difference" , "Exclusion" ) ; if ( ! in_array ( $ mode , $ blend_modes ) ) $ mode = "Normal" ; if ( $ mode ...
Set current blend mode & opacity for lines .
2,709
function setFillTransparency ( $ mode , $ opacity ) { static $ blend_modes = array ( "Normal" , "Multiply" , "Screen" , "Overlay" , "Darken" , "Lighten" , "ColorDogde" , "ColorBurn" , "HardLight" , "SoftLight" , "Difference" , "Exclusion" ) ; if ( ! in_array ( $ mode , $ blend_modes ) ) $ mode = "Normal" ; if ( $ mode ...
Set current blend mode & opacity for filled objects .
2,710
function filledEllipse ( $ x0 , $ y0 , $ r1 , $ r2 = 0 , $ angle = 0 , $ nSeg = 8 , $ astart = 0 , $ afinish = 360 ) { return $ this -> ellipse ( $ x0 , $ y0 , $ r1 , $ r2 = 0 , $ angle , $ nSeg , $ astart , $ afinish , true , true ) ; }
draw a filled ellipse
2,711
function filledRectangle ( $ x1 , $ y1 , $ width , $ height ) { $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= sprintf ( "\n%.3F %.3F %.3F %.3F re f" , $ x1 , $ y1 , $ width , $ height ) ; }
a filled rectangle note that it is the width and height of the rectangle which are the secondary paramaters not the coordinates of the upper - right corner
2,712
function save ( ) { $ this -> currentColour = null ; $ this -> currentStrokeColour = null ; $ this -> objects [ $ this -> currentContents ] [ 'c' ] .= "\nq" ; }
save the current graphic state
2,713
protected function parse ( $ userAgent ) { $ originalUserAgent = $ userAgent ; $ nodesUAPosition = strrpos ( $ userAgent , 'Nodes/' ) ; if ( $ nodesUAPosition !== false ) { $ nodesUserAgent = substr ( $ userAgent , $ nodesUAPosition ) ; $ this -> parseNodesUserAgent ( $ nodesUserAgent ) ; $ originalUserAgent = substr (...
Parse received user agent .
2,714
public function indexAction ( $ attributeId ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ attribute = $ em -> getRepository ( 'EcommerceBundle:Attribute' ) -> find ( $ attributeId ) ; if ( ! $ attribute ) { throw $ this -> createNotFoundException ( 'Unable to find Attribute entity.' ) ; } return array ( 'a...
Lists all AttributeValue entities .
2,715
public function createAction ( Request $ request , $ attributeId ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ attribute = $ em -> getRepository ( 'EcommerceBundle:Attribute' ) -> find ( $ attributeId ) ; if ( ! $ attribute ) { throw $ this -> createNotFoundException ( 'Unable to find Attribute entity.' ) ...
Creates a new AttributeValue entity .
2,716
public function newAction ( $ attributeId ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ attribute = $ em -> getRepository ( 'EcommerceBundle:Attribute' ) -> find ( $ attributeId ) ; if ( ! $ attribute ) { throw $ this -> createNotFoundException ( 'Unable to find Attribute entity.' ) ; } $ entity = new Attr...
Displays a form to create a new AttributeValue entity .
2,717
public function showAction ( $ attributeId , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ attribute = $ em -> getRepository ( 'EcommerceBundle:Attribute' ) -> find ( $ attributeId ) ; if ( ! $ attribute ) { throw $ this -> createNotFoundException ( 'Unable to find Attribute entity.' ) ; } $ entity = ...
Finds and displays a AttributeValue entity .
2,718
public function editAction ( $ attributeId , $ id ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ attribute = $ em -> getRepository ( 'EcommerceBundle:Attribute' ) -> find ( $ attributeId ) ; if ( ! $ attribute ) { throw $ this -> createNotFoundException ( 'Unable to find Attribute entity.' ) ; } $ entity = ...
Displays a form to edit an existing AttributeValue entity .
2,719
private function createDeleteForm ( $ attributeId , $ id ) { return $ this -> createFormBuilder ( array ( 'attributeId' => $ attributeId , 'id' => $ id ) ) -> add ( 'attributeId' , 'hidden' ) -> add ( 'id' , 'hidden' ) -> getForm ( ) ; }
Creates a form to delete a AttributeValue entity by id .
2,720
public function isValidMethod ( $ method ) { $ reflection = $ this -> getReflection ( ) -> getMethod ( $ method ) ; return ! $ reflection -> isAbstract ( ) && $ reflection -> isPublic ( ) && preg_match ( $ this -> methodRule , $ method ) > 0 ; }
Validate if method is routable
2,721
public function getRoutableReflectionMethodList ( ) { $ reflections = [ ] ; foreach ( $ this -> getReflection ( ) -> getMethods ( ) as $ reflection ) { if ( $ this -> isValidMethod ( $ reflection -> name ) ) { $ reflections [ ] = $ reflection ; } } return $ reflections ; }
Get list of ReflectionMethod if is valid routable
2,722
public function generateRoutables ( Router $ router = null , $ prefix = null ) { $ router ? : $ router = new Router ; $ prefix ? : $ prefix = $ this -> buildUriPrefix ( $ this -> reflection -> getShortName ( ) ) ; foreach ( $ this -> getRoutableReflectionMethodList ( ) as $ reflection ) { $ this -> addRouteFromMethod (...
Gets the routable list
2,723
protected function getMethodPartAndVerb ( $ method ) { preg_match ( $ this -> methodRule , $ method , $ matches ) ; return empty ( $ matches ) ? false : array_slice ( $ matches , 1 ) ; }
Gets the data of Method
2,724
protected function createCurrentSiteInfo ( ) { while ( $ this -> queryResult -> valid ( ) ) { $ data = $ this -> queryResult -> current ( ) ; $ current = $ this -> createSiteInfo ( $ data ) ; $ schema = $ current -> getSchema ( ) ; if ( ! empty ( $ this -> queriedSchemas [ $ schema ] ) ) { $ this -> queryResult -> next...
Create current SiteInfo
2,725
public function getVersions ( $ pattern = null ) { $ versions = array_keys ( $ this -> versions ) ; if ( empty ( $ pattern ) ) { return $ versions ; } $ pattern = preg_replace ( '~\.~' , '\\.' , $ pattern ) ; $ pattern = preg_replace ( '~[xyz]+~i' , '\\d+' , $ pattern ) ; $ result = [ ] ; foreach ( $ versions as $ vers...
Get all known version numbers matching a pattern .
2,726
public function getSourceInfo ( $ version = 'latest' , $ ext = null ) { $ info = $ this -> getInfo ( $ version ) ; if ( ! empty ( $ ext ) && isset ( $ info [ 'source' ] [ $ ext ] ) ) { return $ info [ 'source' ] [ $ ext ] ; } foreach ( [ 'xz' , 'bz2' , 'gz' ] as $ ext ) { if ( isset ( $ info [ 'source' ] [ $ ext ] ) ) ...
Get the download information for a specific version .
2,727
public function getInfo ( $ version = 'latest' ) { $ version = $ this -> resolveVersion ( $ version ) ; if ( ! isset ( $ this -> versions [ $ version ] ) ) { throw new \ Exception ( "No information for version $version." ) ; } return $ this -> versions [ $ version ] ; }
Get information about a specific version .
2,728
public function createImportFile ( ) { @ unlink ( $ this -> localPath ) ; $ fp = fopen ( $ this -> localPath , 'w' ) ; fwrite ( $ fp , $ this -> xmlStart ) ; foreach ( $ this -> elements as $ element ) { fwrite ( $ fp , $ element -> getXml ( ) ) ; } fwrite ( $ fp , $ this -> xmlEnd ) ; fclose ( $ fp ) ; return $ this -...
Returns the local path of the file
2,729
protected function runSeeder ( $ database ) { $ class = $ this -> option ( 'seeder' ) ? : 'DatabaseSeeder' ; $ force = $ this -> input -> getOption ( 'force' ) ; $ this -> call ( 'db:seed' , array ( '--database' => $ database , '--class' => $ class , '--force' => $ force , ) ) ; }
Run the database seeder command .
2,730
public function writeInt8 ( int $ value ) : self { $ this -> bytes .= Writer :: bit8 ( $ value ) ; return $ this ; }
Write a signed 8 bit integer .
2,731
public function writeInt16 ( int $ value ) : self { $ this -> bytes .= Writer :: bit16 ( $ value ) ; return $ this ; }
Write a signed 16 bit integer .
2,732
public function writeInt32 ( int $ value ) : self { $ this -> bytes .= Writer :: bit32 ( $ value ) ; return $ this ; }
Write a signed 32 bit integer .
2,733
public function writeInt64 ( int $ value ) : self { $ this -> bytes .= Writer :: bit64 ( $ value ) ; return $ this ; }
Write a signed 64 bit integer .
2,734
public function addModule ( $ key , Module $ module ) { $ this -> _modules [ $ key ] = $ module ; $ module -> setApplication ( $ this ) ; $ module -> bootstrap ( $ this ) ; if ( $ module instanceof Listener ) { $ this -> on ( 'mvc' , $ module ) ; } return $ module ; }
Add a module into the application .
2,735
public function createLinks ( $ web ) { $ web = Path :: ds ( $ web , true ) ; foreach ( $ this -> getModules ( ) as $ key => $ module ) { $ moduleWeb = $ module -> getPath ( ) . 'web' . Path :: SEPARATOR ; if ( ! file_exists ( $ moduleWeb ) ) { continue ; } $ targetLink = $ web . $ key . Path :: SEPARATOR ; if ( ! file...
Create symbolic links to the webroot folder within each module . This allows for direct static asset handling .
2,736
public function get ( $ key ) { if ( isset ( $ this -> _components [ $ key ] ) ) { return $ this -> _components [ $ key ] ; } throw new MissingComponentException ( sprintf ( 'Application component %s does not exist' , $ key ) ) ; }
Return a component by key .
2,737
public function getModule ( $ key ) { if ( isset ( $ this -> _modules [ $ key ] ) ) { return $ this -> _modules [ $ key ] ; } throw new MissingModuleException ( sprintf ( 'Could not locate %s module' , $ key ) ) ; }
Return a module by key .
2,738
public function handleAsset ( $ params ) { $ response = $ this -> getResponse ( ) ; $ path = null ; try { $ module = $ this -> getModule ( $ params [ 'module' ] ) ; $ path = implode ( '/' , [ $ module -> getPath ( ) , 'web' , $ params [ 'asset' ] , $ params [ 'path' ] ] ) ; $ this -> emit ( 'mvc.preAsset' , [ $ this , ...
Handle a static asset by outputting the file contents and size to the browser . If the asset does not exist throw a 404 and exit .
2,739
public function handleError ( Exception $ exception ) { if ( class_exists ( 'Titon\Debug\Debugger' ) ) { Debugger :: logException ( $ exception ) ; } try { $ controller = Registry :: get ( 'titon.controller' ) ; if ( ! ( $ controller instanceof Controller ) ) { throw new MissingControllerException ( ) ; } } catch ( Exc...
Default mechanism for handling uncaught exceptions . Will fetch the current controller instance or instantiate an ErrorController . The error view template will be rendered .
2,740
public function run ( $ webroot ) { $ this -> _webroot = $ webroot ; $ this -> getRequest ( ) -> set ( 'webroot' , $ webroot ) ; $ this -> createLinks ( $ webroot ) ; $ this -> emit ( 'mvc.preRun' , [ $ this ] ) ; $ dispatcher = $ this -> getDispatcher ( ) ; $ dispatcher -> setApplication ( $ this ) ; $ dispatcher -> s...
Run the application by fetching the dispatcher and dispatching the request to the module and controller that matches the current URL .
2,741
public function set ( $ key , $ object ) { $ this -> _components [ $ key ] = Registry :: set ( $ object ) ; return $ this ; }
Set an object to use throughout the application .
2,742
public function setRouter ( Router $ router ) { $ this -> set ( 'router' , $ router ) ; $ this -> _router = $ this -> get ( 'router' ) ; return $ this ; }
Set the router .
2,743
public function execute ( Framework $ framework , RequestAbstract $ request , Response $ response , $ value = null ) { $ permissions = array ( ) ; foreach ( $ value as $ accessLevel ) { $ parts = explode ( '\\' , $ accessLevel ) ; if ( $ parts [ 1 ] === 'Group' && count ( $ parts ) === 3 ) { $ uuid = $ parts [ 2 ] ; $ ...
Replaces all group access levels with the permissions of the group
2,744
private function renderEmbeddedFiles ( & $ content , $ boundary ) { foreach ( $ this -> cids as $ image => $ cid ) { if ( ! is_readable ( $ image ) ) { throw new MailException ( 'Image could bot be read: ' . $ image ) ; } $ type = self :: getMimeTypeOfImage ( $ image ) ; $ name = basename ( $ image ) ; $ data = chunk_s...
Render embedded files into the given content .
2,745
private function renderAttachments ( & $ content , $ boundary ) { foreach ( $ this -> attachments as $ file => $ name ) { if ( ! is_readable ( $ file ) ) { throw new MailException ( 'File could not be read: ' . $ file ) ; } $ data = chunk_split ( base64_encode ( file_get_contents ( $ file ) ) ) ; $ type = mime_content_...
Render attachments into the given content .
2,746
private function renderPlainText ( & $ content , $ text , $ encoding , $ boundary ) { $ content .= "\r\n" ; $ content .= "--$boundary\r\n" ; $ content .= "Content-Type: text/plain;\r\n\tcharset=\"$encoding\"\r\n" ; $ content .= "Content-Transfer-Encoding: quoted-printable\r\n" ; $ content .= "\r\n" ; $ content .= "$tex...
Render plain text into the given content .
2,747
private function renderHtml ( & $ content , $ html , $ encoding , $ boundary ) { $ content .= "\r\n" ; $ content .= "--$boundary\r\n" ; $ content .= "Content-Type: text/html;\r\n\tcharset=\"$encoding\"\r\n" ; $ content .= "Content-Transfer-Encoding: quoted-printable\r\n" ; $ content .= "\r\n" ; $ content .= "$html\r\n"...
Render HTML into the given content .
2,748
private function renderTextAndHtml ( & $ content , $ text , $ html , $ encoding , $ boundary ) { $ uid = uniqid ( ) ; $ boundary2 = "x----_=_NextPart_003_$uid" ; $ content .= "\r\n--$boundary\r\n" ; $ content .= "Content-Type: multipart/alternative;\r\n\tboundary=\"$boundary2\"\r\n" ; $ this -> renderPlainText ( $ cont...
Render text and html into the given content .
2,749
private function renderTextAndHtmlWithEmbededFiles ( & $ content , $ text , $ html , $ encoding , $ boundary ) { $ uid = uniqid ( ) ; $ boundary2 = "x----_=_NextPart_002_$uid" ; $ content .= "\r\n--$boundary\r\n" ; $ content .= "Content-Type: multipart/related;\r\n\tboundary=\"$boundary2\";\r\n\ttype=\"multipart/altern...
Render text and html with embedded files into the given content .
2,750
private static function getMimeTypeOfImage ( $ image ) { static $ mimes ; if ( $ mimes === null ) { $ mimes = [ 'cod' => 'image/cis-cod' , 'ras' => 'image/cmu-raster' , 'fif' => 'image/fif' , 'gif' => 'image/gif' , 'ief' => 'image/ief' , 'jpeg' => 'image/jpeg' , 'jpg' => 'image/jpeg' , 'jpe' => 'image/jpeg' , 'png' => ...
Gets the MIME Type of the given image .
2,751
private function justAddress ( $ address ) { if ( ( $ pos = strpos ( $ address , '<' ) ) === false ) { return $ address ; } $ n = strlen ( $ address ) ; if ( $ address [ $ n - 1 ] == '>' ) { $ address = substr ( $ address , $ pos + 1 , - 1 ) ; } return $ address ; }
Get the address without the name .
2,752
private function findAddress ( $ needle , array $ haystack ) { $ address = $ this -> justAddress ( $ needle ) ; foreach ( $ haystack as $ i => $ item ) { if ( $ this -> justAddress ( $ item ) == $ address ) { return $ i ; } } return false ; }
Get the index of the given address .
2,753
public static function save ( $ file , $ lang , $ language = null ) { ( $ language === null ) and $ language = static :: get_lang ( ) ; if ( ! is_null ( $ language ) ) { $ file = explode ( '::' , $ file ) ; end ( $ file ) ; $ file [ key ( $ file ) ] = $ language . DS . end ( $ file ) ; $ file = implode ( '::' , $ file ...
Save a language array to disk .
2,754
public function getFallbackThemes ( $ name ) { if ( ! isset ( $ this -> data [ $ name ] [ 'fallbacks' ] ) ) { return array ( ) ; } if ( ! is_array ( $ this -> data [ $ name ] [ 'fallbacks' ] ) && ! ( $ this -> data [ $ name ] [ 'fallbacks' ] instanceof Traversable ) ) { return array ( ( string ) $ this -> data [ $ name...
Retrieve the fallback theme
2,755
function setLabel ( $ label ) { $ label = str_replace ( ' ' , '-' , ucwords ( str_replace ( [ '_' , '-' ] , ' ' , ( string ) $ label ) ) ) ; if ( ! isValidLabel ( $ label ) ) throw new \ InvalidArgumentException ( sprintf ( 'Invalid header name "%s".' , is_null ( $ label ) ? 'null' : $ label ) ) ; $ this -> label = $ l...
Set Header Label
2,756
function render ( ) { $ label = $ this -> getLabel ( ) ; if ( empty ( $ label ) ) throw new \ Exception ( 'Header label is empty.' ) ; return $ label . ': ' . $ this -> renderValueLine ( ) . self :: CRLF ; }
Represent Header As String
2,757
public function json ( $ forceJson = false , $ returnAllIfNotJson = true ) { if ( $ forceJson || $ this -> isJson ( ) ) { return json_decode ( $ this -> getContent ( ) ) ; } if ( ! $ returnAllIfNotJson ) { return null ; } return ( object ) $ this -> all ( ) ; }
Get json request .
2,758
public function accept ( $ accept , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: ACCEPT , 'value' => $ accept , 'message' => $ error ] ) ; } return $ this ; }
file types accepted
2,759
public function extension ( $ extension , $ error ) { if ( $ this -> _exist ) { array_push ( $ this -> _constraints , [ 'type' => self :: EXTENSION , 'value' => $ extension , 'message' => $ error ] ) ; } return $ this ; }
file extensions accepted
2,760
public function setDateFormat ( Event $ e ) { $ form = $ e -> getParam ( 'form' ) ; $ hydrator = $ form -> getHydrator ( ) ; $ dateTimeStrategy = $ hydrator -> getStrategy ( 'dateTime' ) ; $ dateTimeStrategy -> setHydrateFormat ( $ this -> getOptions ( ) -> getDateFormat ( ) ) ; }
Add date format
2,761
public function validateImplementation ( ) { $ required = [ 'model' => ' does not implement a model definition.' , 'resource_path' => ' does not implement a resource path definition.' , ] ; foreach ( $ required as $ implementation => $ message ) { if ( ! isset ( $ this -> { $ implementation } ) ) { throw new \ InvalidA...
Make sure a model has been defined for this restful resource
2,762
public function model ( $ instance = false ) { if ( ! isset ( $ this -> model ) ) { throw new \ InvalidArgumentException ( static :: class . ' does not implement a model definition.' ) ; } return $ instance ? new $ this -> model : $ this -> model ; }
Get the model class
2,763
public function path ( $ id = null ) { if ( ! isset ( $ this -> resource_path ) ) { throw new \ InvalidArgumentException ( static :: class . ' does not implement a resource path definition.' ) ; } return is_null ( $ id ) ? $ this -> url ( $ this -> resource_path ) : $ this -> url ( "$this->resource_path/$id" ) ; }
Find the resource path
2,764
protected function makeGenericUpdate ( Model $ model ) { $ field = array_first ( $ model -> getFillable ( ) , function ( $ key , $ value ) use ( $ model ) { return ( $ value !== $ model -> getKeyName ( ) ) ; } ) ; switch ( gettype ( $ model -> { $ field } ) ) { case 'string' : $ model -> { $ field } = $ model -> { $ fi...
Makes a generic update on the first fillable attribute but avoiding the primary key .
2,765
public function getPolicyByHostname ( $ name ) { if ( ! $ this -> inventory -> hasHost ( $ name ) ) { return array ( ) ; } $ policy = array ( ) ; $ host = $ this -> inventory -> getHost ( $ name ) ; foreach ( $ this -> inventory -> getHostGroupsByHost ( $ host ) as $ group ) { $ policy = array_replace_recursive ( $ pol...
Get the firewall policy for the named host .
2,766
private function getInstanceHelper ( $ config ) { if ( is_callable ( $ config ) ) { return $ config ; } if ( ! isset ( $ config [ 'class_name' ] ) ) { throw new Exception \ RuntimeException ( 'Config router convert miss "class_name"' ) ; } $ className = $ config [ 'class_name' ] ; if ( ! class_exists ( $ className ) ) ...
Base on config for convertion get callable
2,767
protected function setHttpMethods ( Route $ route , array $ httpMethods ) { foreach ( $ httpMethods as $ idx => $ method ) { $ httpMethods [ $ idx ] = strtoupper ( $ method ) ; } $ route -> via ( $ httpMethods ) ; }
Set Http methods constraints for router
2,768
public function addRoute ( $ name , array $ routeInfo ) { if ( ! isset ( $ routeInfo [ 'route' ] ) || ! isset ( $ routeInfo [ 'definitions' ] ) ) { $ errMsg = 'Not found required configs for router. Maybe miss "route" or "definitions"' ; throw new Exception \ InvalidArgumentException ( $ errMsg ) ; } $ route = $ this -...
Add route by array config
2,769
public function setConnectionParameters ( string $ driver = 'mysql' , string $ host , string $ database , string $ user , string $ pass ) { $ this -> driver = $ driver ; $ this -> host = $ host ; $ this -> database = $ database ; $ this -> user = $ user ; $ this -> pass = $ pass ; }
Setup the connection parameters for PDO
2,770
public function generateNewPDO ( ) : \ PDO { if ( $ this -> validateConfig ( ) ) { $ dns = $ this -> driver . ':dbname=' . $ this -> database . ";host=" . $ this -> host ; return new \ PDO ( $ dns , $ this -> user , $ this -> pass ) ; } else { throw ( new \ Exception ( "Invalid or missing database connection parameters...
Generate a new PDO instance using validated parameters or throw an Exception
2,771
private function calculateLanguagesPercentage ( $ languages ) { $ total = $ languages -> sum ( 'count' ) ; return $ languages -> transform ( function ( $ item ) use ( $ total ) { return $ item + [ 'percentage' => round ( ( $ item [ 'count' ] / $ total ) * 100 , 2 ) ] ; } ) ; }
Calculate the languages percentage .
2,772
public function editPage ( $ title , $ section = null , $ sectiontitle = null , $ text = null , $ summary = null ) { $ token = $ this -> getToken ( $ title , 'edit' ) ; $ path = '?action=edit' ; $ data = array ( 'title' => $ title , 'token' => $ token , 'section' => $ section , 'sectiontitle' => $ section , 'text' => $...
Method to edit a page .
2,773
public function undeletePage ( $ title , $ reason = null , $ timestamp = null , $ watchlist = null ) { $ token = $ this -> getToken ( $ title , 'undelete' ) ; $ path = '?action=undelete' ; $ data = array ( 'title' => $ title , 'token' => $ token , 'reason' => $ reason , 'timestamp' => $ timestamp , 'watchlist' => $ wat...
Method to restore certain revisions of a deleted page .
2,774
public function movePageByName ( $ from , $ to , $ reason = null , $ movetalk = null , $ movesubpages = null , $ noredirect = null , $ watchlist = null , $ ignorewarnings = null ) { $ token = $ this -> getToken ( $ from , 'move' ) ; $ path = '?action=move' ; $ data = array ( 'from' => $ from , 'to' => $ reason , 'token...
Method to move a page .
2,775
public function rollback ( $ title , $ user , $ summary = null , $ markbot = null , $ watchlist = null ) { $ token = $ this -> getToken ( $ title , 'rollback' ) ; $ path = '?action=rollback' ; $ data = array ( 'title' => $ title , 'token' => $ token , 'user' => $ user , 'expiry' => $ summary , 'markbot' => $ markbot , ...
Method to undo the last edit to the page .
2,776
public function changeProtection ( $ title , $ protections , $ expiry = null , $ reason = null , $ cascade = null , $ watchlist = null ) { $ token = $ this -> getToken ( $ title , 'unblock' ) ; $ path = '?action=protect' ; $ data = array ( 'title' => $ title , 'token' => $ token , 'protections' => $ protections , 'expi...
Method to change the protection level of a page .
2,777
public function getPageInfo ( array $ titles , array $ inprop = null , array $ intoken = null , $ incontinue = null ) { $ path = '?action=query&prop=info' ; $ path .= '&titles=' . $ this -> buildParameter ( $ titles ) ; if ( isset ( $ inprop ) ) { $ path .= '&inprop=' . $ this -> buildParameter ( $ inprop ) ; } if ( is...
Method to get basic page information .
2,778
public function getPageProperties ( array $ titles , $ ppcontinue = null , $ ppprop = null ) { $ path = '?action=query&prop=pageprops' ; $ path .= '&titles=' . $ this -> buildParameter ( $ titles ) ; if ( $ ppcontinue ) { $ path .= '&ppcontinue=' ; } if ( isset ( $ ppprop ) ) { $ path .= '&ppprop=' . $ ppprop ; } $ res...
Method to get various properties defined in the page content .
2,779
public function getRevisions ( array $ titles , array $ rvprop = null , $ rvparse = null , $ rvlimit = null ) { $ path = '?action=query&prop=revisions' ; $ path .= '&titles=' . $ this -> buildParameter ( $ titles ) ; if ( isset ( $ rvprop ) ) { $ path .= '&rvprop=' . $ this -> buildParameter ( $ rvprop ) ; } if ( $ rvp...
Method to get a list of revisions .
2,780
public function getPageTemplates ( array $ titles , array $ tlnamespace = null , $ tllimit = null , $ tlcontinue = null , $ tltemplates = null , $ tldir = null ) { $ path = '?action=query&prop=templates' ; $ path .= '&titles=' . $ this -> buildParameter ( $ titles ) ; if ( isset ( $ tlnamespace ) ) { $ path .= '&tlname...
Method to get all page templates from the given page .
2,781
public function getBackLinks ( $ bltitle , $ blpageid = null , $ blcontinue = null , array $ blnamespace = null , $ blfilterredirect = null , $ bllimit = null , $ blredirect = null ) { $ path = '?action=query&list=backlinks' ; if ( isset ( $ bltitle ) ) { $ path .= '&bltitle=' . $ bltitle ; } if ( isset ( $ blpageid ) ...
Method to get all pages that link to the given page .
2,782
public function getIWBackLinks ( $ iwbltitle , $ iwblprefix = null , $ iwblcontinue = null , $ iwbllimit = null , array $ iwblprop = null ) { $ path = '?action=query&list=iwbacklinks' ; if ( isset ( $ iwbltitle ) ) { $ path .= '&iwbltitle=' . $ iwbltitle ; } if ( isset ( $ iwblprefix ) ) { $ path .= '&iwblprefix=' . $ ...
Method to get all pages that link to the given interwiki link .
2,783
public function getToken ( $ user , $ intoken ) { $ path = '?action=query&prop=info&intoken=' . $ intoken . '&titles=User:' . $ user ; $ response = $ this -> client -> post ( $ this -> fetchUrl ( $ path ) , null ) ; return ( string ) $ this -> validateResponse ( $ response ) -> query -> pages -> page [ $ intoken . 'tok...
Method to get access token .
2,784
public function macroOnLoad ( MacroNode $ node , PhpWriter $ writer ) : string { if ( $ node -> args == '' ) { throw new CompileException ( 'Missing function name argument in {onLoad} macro.' ) ; } return $ writer -> write ( ' if($presenter->isAjax()) { echo "' . $ node -> args . '();"; ...
onLoad pro javascript
2,785
public function connect ( \ OtherCode \ FController \ Components \ Services $ services , \ OtherCode \ FController \ Components \ Registry $ storage , \ OtherCode \ FController \ Components \ Messages $ messages ) { if ( ! isset ( $ this -> services ) ) { $ this -> services = $ services ; } if ( ! isset ( $ this -> sto...
Load the services into the module if they have not loaded already
2,786
public function exists ( $ category , $ post ) { $ ds = DIRECTORY_SEPARATOR ; $ postPath = str_replace ( '/' , $ ds , $ category . $ ds . $ post ) ; $ fullPostPath = app_path ( ) . $ ds . 'lablog' . $ ds . $ postPath . '.post' ; if ( $ this -> fs -> exists ( $ fullPostPath ) ) { return true ; } return false ; }
Check that a post exists .
2,787
public function getAll ( $ category ) { $ ds = DIRECTORY_SEPARATOR ; $ category = str_replace ( '/' , $ ds , $ category ) ; $ path = app_path ( ) . $ ds . 'lablog' . $ ds . $ category ; $ posts = $ this -> fs -> files ( $ path ) ; $ allPosts = array ( ) ; foreach ( $ posts as $ post ) { if ( strpos ( $ post , '.post' )...
Get all files from the blog of specified category .
2,788
public function newAction ( Request $ request ) { $ provincium = new Provincia ( ) ; $ form = $ this -> createForm ( 'Matudelatower\UbicacionBundle\Form\Type\ProvinciaType' , $ provincium ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine...
Creates a new Provincia entity .
2,789
public function showAction ( Provincia $ provincium ) { $ deleteForm = $ this -> createDeleteForm ( $ provincium ) ; return $ this -> render ( 'UbicacionBundle:provincia:show.html.twig' , array ( 'provincium' => $ provincium , 'delete_form' => $ deleteForm -> createView ( ) , ) ) ; }
Finds and displays a Provincia entity .
2,790
public function deleteAction ( Request $ request , Provincia $ provincium ) { $ form = $ this -> createDeleteForm ( $ provincium ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> remove ( $ provincium ) ; ...
Deletes a Provincia entity .
2,791
private function createDeleteForm ( Provincia $ provincium ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'provincia_delete' , array ( 'id' => $ provincium -> getId ( ) ) ) ) -> setMethod ( 'DELETE' ) -> getForm ( ) ; }
Creates a form to delete a Provincia entity .
2,792
public function toast ( $ toast , $ displayTime = null , $ class = null ) { if ( ! $ toast instanceof Toast ) { $ toast = new Toast ( $ toast , $ displayTime , $ class ) ; } $ this -> container -> add ( $ toast ) ; return $ this ; }
Add a toast message
2,793
public static function romanToInt ( $ str = null ) { if ( is_null ( $ str ) ) { return null ; } if ( $ str == self :: $ romans_letters [ 0 ] ) { return 0 ; } if ( ! self :: isRomanNumber ( $ str ) ) { return false ; } $ result = 0 ; $ length = strlen ( $ str ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ index = arr...
Get the integer equivalent from roman notation
2,794
public static function intToRoman ( $ a = null ) { if ( is_null ( $ a ) ) { return null ; } if ( $ a > 4999 ) { return null ; } if ( $ a == 0 ) { return self :: $ romans_letters [ 0 ] ; } $ a = ( string ) $ a ; $ ctt = '' ; $ counter = 1 ; for ( $ i = ( strlen ( $ a ) - 1 ) ; $ i >= 0 ; $ i -- ) { $ tmp_ctt = '' ; $ ch...
Get the roman notation of a number inferior to 5000
2,795
public static function get ( $ code = 200 ) { if ( isset ( self :: $ http_status_codes [ $ code ] ) ) { return ( self :: $ http_status_codes [ $ code ] ) ; } return ( false ) ; }
Take a http response code and return the textual representation
2,796
public function get ( $ index ) { $ index = intval ( $ index ) ; $ i = 0 ; foreach ( $ this -> getInnerIterator ( ) as $ v ) { if ( $ i == $ index ) { return $ v ; } $ i ++ ; } return null ; }
Get a value by numeric index .
2,797
public function callback ( Closure $ callback ) { foreach ( $ this -> getInnerIterator ( ) as $ key => $ value ) { yield $ callback ( $ value , $ key ) ; } }
Maps a callback over all entries .
2,798
public static function createXml ( $ nodeName , $ arr = [ ] , $ version = '1.0' , $ encoding = 'UTF-8' , $ formatOutput = true ) { $ class = new self ( $ version , $ encoding , $ formatOutput ) ; $ class -> xml -> appendChild ( $ class -> convert ( $ nodeName , $ arr ) ) ; return $ class -> xml ; }
This method converts an array to XML .
2,799
public static function getXmlString ( $ nodeName , $ arr = [ ] , $ version = '1.0' , $ encoding = 'UTF-8' , $ formatOutput = true ) { return self :: createXml ( $ nodeName , $ arr , $ version , $ encoding , $ formatOutput ) -> saveXML ( ) ; }
This method returns the string representation of DOMDocument .