idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
234,000
public function registerDoctrineLazyLoader ( $ entityClass , LazyLoaderInterface $ loader ) { if ( ! is_a ( $ entityClass , LazyPropertiesInterface :: class , true ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Class %s has to implement %s to be able to lazy load her properties.' , $ entityClass , LazyProperti...
Register a loader for given entity class .
234,001
public function postLoad ( LifecycleEventArgs $ event ) { if ( ! $ loader = $ this -> getLoader ( $ entity = $ event -> getEntity ( ) ) ) { return ; } if ( isset ( $ proxies [ $ loaderClass = static :: class ] ) ) { @ trigger_error ( sprintf ( 'Global loader delegate is deprecated and will be removed in 2.0. Make "%s" ...
postLoad Doctrine event handler notify loaders if define for given event related entity .
234,002
private function createConnection ( array $ persisterConfig , $ configName ) { $ options = isset ( $ persisterConfig [ 'parameters' ] [ 'options' ] ) && is_array ( $ persisterConfig [ 'parameters' ] [ 'options' ] ) ? $ persisterConfig [ 'parameters' ] [ 'options' ] : [ ] ; $ definition = new Definition ( 'Doctrine\Mong...
Creates the connection service definition .
234,003
private function createDataCollector ( ) { $ definition = new Definition ( Utility :: getBundleClass ( 'DataCollector\MongoDb\PrettyDataCollector' ) ) ; $ definition -> addTag ( 'data_collector' , [ 'id' => 'as3persistermongodb' , 'template' => 'As3ModlrBundle:Collector:mongodb' ] ) ; $ definition -> setPublic ( false ...
Creates the persistence data collector service definition .
234,004
private function createMongoDbPersister ( $ persisterName , array $ persisterConfig , ContainerBuilder $ container ) { $ smfName = sprintf ( '%s.metadata' , $ persisterName ) ; $ definition = $ this -> createSmf ( ) ; $ container -> setDefinition ( $ smfName , $ definition ) ; $ configName = sprintf ( '%s.configuration...
Creates the MongoDB persister service definition . Will also load support services .
234,005
private function createSmf ( ) { $ definition = new Definition ( Utility :: getLibraryClass ( 'Persister\MongoDb\StorageMetadataFactory' ) , [ new Reference ( Utility :: getAliasedName ( 'util.entity' ) ) ] ) ; $ definition -> setPublic ( false ) ; return $ definition ; }
Creates the storage metadata factory service definition .
234,006
public function indexAction ( ) { $ em = $ this -> getDoctrineManager ( ) ; $ sakonninTemplates = $ em -> getRepository ( 'BisonLabSakonninBundle:SakonninTemplate' ) -> findAll ( ) ; return $ this -> render ( 'BisonLabSakonninBundle:SakonninTemplate:index.html.twig' , array ( 'sakonninTemplates' => $ sakonninTemplates ...
Lists all sakonninTemplate entities .
234,007
public function newAction ( Request $ request ) { $ sakonninTemplate = new Sakonnintemplate ( ) ; $ default_lang_code = $ this -> container -> get ( 'translator' ) -> getLocale ( ) ; $ sakonninTemplate -> setLangCode ( $ default_lang_code ) ; $ form = $ this -> createForm ( 'BisonLab\SakonninBundle\Form\SakonninTemplat...
Creates a new sakonninTemplate entity .
234,008
public function showAction ( SakonninTemplate $ sakonninTemplate ) { $ deleteForm = $ this -> createDeleteForm ( $ sakonninTemplate ) ; return $ this -> render ( 'BisonLabSakonninBundle:SakonninTemplate:show.html.twig' , array ( 'sakonninTemplate' => $ sakonninTemplate , 'delete_form' => $ deleteForm -> createView ( ) ...
Finds and displays a sakonninTemplate entity .
234,009
public function editAction ( Request $ request , SakonninTemplate $ sakonninTemplate ) { $ deleteForm = $ this -> createDeleteForm ( $ sakonninTemplate ) ; $ editForm = $ this -> createForm ( 'BisonLab\SakonninBundle\Form\SakonninTemplateType' , $ sakonninTemplate ) ; $ editForm -> handleRequest ( $ request ) ; if ( $ ...
Displays a form to edit an existing sakonninTemplate entity .
234,010
public function deleteAction ( Request $ request , SakonninTemplate $ sakonninTemplate ) { $ form = $ this -> createDeleteForm ( $ sakonninTemplate ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrineManager ( ) ; $ em -> remove ( $ sakonni...
Deletes a sakonninTemplate entity .
234,011
private function createDeleteForm ( SakonninTemplate $ sakonninTemplate ) { return $ this -> createFormBuilder ( ) -> setAction ( $ this -> generateUrl ( 'sakonnintemplate_delete' , array ( 'id' => $ sakonninTemplate -> getId ( ) ) ) ) -> setMethod ( 'DELETE' ) -> getForm ( ) ; }
Creates a form to delete a sakonninTemplate entity .
234,012
public function toSQL ( Parameters $ params , bool $ inner_clause ) { $ drv = $ params -> getDriver ( ) ; $ table = $ drv -> toSQL ( $ params , $ this -> getTable ( ) ) ; $ condition = $ drv -> toSQL ( $ params , $ this -> getCondition ( ) ) ; return $ this -> getType ( ) . " JOIN " . $ table . " ON " . $ condition ; }
Write a JOIN clause to SQL query syntax
234,013
public function download ( $ ftkey , $ size , $ passthru = false ) { $ this -> init ( $ ftkey ) ; if ( $ passthru ) { return $ this -> passthru ( $ size ) ; } $ buff = new String ( "" ) ; $ size = intval ( $ size ) ; $ pack = 4096 ; Signal :: getInstance ( ) -> emit ( "filetransferDownloadStarted" , $ ftkey , count ( $...
Returns the content of a downloaded file as a String object .
234,014
static public function isValid ( $ direction , $ throw = false ) { $ valid = in_array ( $ direction , [ static :: NONE , static :: ASC , static :: DESC , ] , true ) ; if ( ! $ valid && $ throw ) { throw new InvalidArgumentException ( sprintf ( "The direction '%s' is not valid." , $ direction ) ) ; } return $ valid ; }
Returns whether the given direction is valid .
234,015
public static function configure ( $ object , $ properties ) { foreach ( $ properties as $ name => $ value ) { if ( ! property_exists ( $ object , $ name ) ) { throw new InvalidConfigException ( sprintf ( 'Property %s in class %s not found.' , $ name , \ get_class ( $ object ) ) ) ; } $ object -> $ name = $ value ; } r...
Configures an object with the initial property values . Inspired by Yii2 .
234,016
public static function createObject ( $ type ) { if ( \ is_string ( $ type ) ) { return static :: get ( $ type ) ; } elseif ( \ is_array ( $ type ) ) { if ( ! isset ( $ type [ 'class' ] ) ) { throw new InvalidConfigException ( 'Object configuration must be an array containing a "class" element.' ) ; } $ class = $ type ...
Creates a new object using the given configuration . Inspired by Yii2 .
234,017
public static function get ( string $ class , array $ config = [ ] ) { $ reflection = new \ ReflectionClass ( $ class ) ; if ( ! $ reflection -> isInstantiable ( ) ) { throw new \ ReflectionException ( sprintf ( '`%s` is not instantiable.' , $ reflection -> name ) ) ; } if ( $ reflection -> implementsInterface ( IConfi...
Creates an instance of the specified class . Inspired by Yii2 di .
234,018
public function generate ( $ length = 16 , $ alpha = 0.6 , $ numeric = 0.2 , $ other = 0.2 ) { $ chars = array ( ) ; for ( $ index = 0 , $ max = ceil ( $ alpha * $ length ) ; $ index < $ max ; $ index ++ ) { if ( ( bool ) rand ( 0 , 1 ) ) { $ char = rand ( 65 , 90 ) ; } else { $ char = rand ( 97 , 122 ) ; } $ chars [ ]...
Generate password of given length .
234,019
protected function configureOptions ( InputInterface $ input ) { if ( $ input -> getOption ( 'path' ) ) { $ this -> finder -> setPath ( $ input -> getOption ( 'path' ) ) ; $ this -> locator -> setParams ( array ( 'path' => $ input -> getOption ( 'path' ) ) ) ; } }
Configure input options
234,020
protected function display ( OutputInterface $ output , array $ rows = array ( ) , array $ failed = array ( ) ) { $ this -> getApplication ( ) -> getHelperSet ( ) -> get ( 'table' ) -> setHeaders ( array ( 'Name' , 'Scripts' , 'Rollbacks' , 'Status' ) ) -> setRows ( $ rows ) -> render ( $ output ) ; if ( ! empty ( $ fa...
Display result as a table
234,021
public static function toRoute ( $ route , $ scheme = false ) { $ route = ( array ) $ route ; $ route [ 0 ] = static :: normalizeRoute ( $ route [ 0 ] ) ; if ( $ scheme ) { return Yii :: $ app -> getUrlManager ( ) -> createAbsoluteUrl ( $ route , is_string ( $ scheme ) ? $ scheme : null ) ; } else { return Yii :: $ app...
Creates a URL for the given route .
234,022
public static function to ( $ url = '' , $ scheme = false ) { if ( is_array ( $ url ) ) { return static :: toRoute ( $ url , $ scheme ) ; } $ url = Yii :: getAlias ( $ url ) ; if ( $ url === '' ) { $ url = Yii :: $ app -> getRequest ( ) -> getUrl ( ) ; } if ( ! $ scheme ) { return $ url ; } if ( strncmp ( $ url , '//' ...
Creates a URL based on the given parameters .
234,023
public function buildRepository ( string $ key ) { $ repositoryInfo = $ this -> get ( $ key ) ; if ( is_null ( $ repositoryInfo ) ) { throw new \ Nuki \ Exceptions \ Base ( vsprintf ( '%1$s is not a registered repository' , [ $ key ] ) ) ; } $ this -> validate ( $ repositoryInfo , $ key ) ; $ repository = new $ reposit...
Build a repository by its key and additional options
234,024
private function validate ( array $ repository = [ ] , $ key ) { if ( ! isset ( $ repository [ 'Providers' ] ) || empty ( $ repository [ 'Providers' ] ) ) { throw new \ Nuki \ Exceptions \ Base ( vsprintf ( '%1$s does not have any providers' , [ $ key ] ) ) ; } if ( ! class_exists ( $ repository [ 'Location' ] ) ) { th...
Validate repository info
234,025
public function getConnection ( $ name = null ) { if ( $ name === null ) { reset ( $ this -> config ) ; $ name = key ( $ this -> config ) ; } if ( ! isset ( $ this -> config [ $ name ] ) ) { throw new \ Exception ( 'Configuration name does not exists !' ) ; } if ( ! isset ( $ this -> config [ $ name ] [ 'engine' ] ) ) ...
Create or get existing connection .
234,026
protected function getPDO ( $ name ) { if ( ! isset ( $ this -> config [ $ name ] ) || ! is_array ( $ this -> config [ $ name ] ) ) { throw new \ Exception ( 'Config not found ! (config: ' . $ name . ')' ) ; } $ config = $ this -> config [ $ name ] ; if ( ! isset ( $ config [ 'dsn' ] ) ) { throw new \ Exception ( '"dsn...
Create new PDO connection
234,027
private function registerDefaultServices ( $ userSettings ) { $ defaultSettings = $ this -> defaultSettings ; $ this [ 'settings' ] = function ( ) use ( $ userSettings , $ defaultSettings ) { return new Collection ( array_merge ( $ defaultSettings , $ userSettings ) ) ; } ; $ defaultProvider = new DefaultServicesProvid...
This function registers the default services that Mbh needs to work .
234,028
public function splitInner ( array $ arguments = array ( ) ) { if ( is_null ( $ this -> _InnerSplitter ) ) { return new ArrayIterator ( array ( $ arguments ) ) ; } return $ this -> _InnerSplitter -> split ( $ arguments ) ; }
Returns iterator over arguments splitted by inner splitter
234,029
public function connect ( ) { $ this -> link = mysql_connect ( $ this -> addr , $ this -> user , $ this -> passwd ) ; if ( $ this -> link === false ) { throw new Klarna_DatabaseException ( 'Failed to connect to database! (' . mysql_error ( ) . ')' ) ; } }
Establish a connection to the DB
234,030
public function create ( ) { if ( ! mysql_query ( "CREATE DATABASE IF NOT EXISTS `{$this->dbName}`" , $ this -> link ) ) { throw new Klarna_DatabaseException ( 'Failed to create! (' . mysql_error ( ) . ')' ) ; } $ create = mysql_query ( "CREATE TABLE IF NOT EXISTS `{$this->dbName}`.`{$this->dbTable}` ( `...
Initialize the DB by creating the necessary database tables .
234,031
public function save ( $ uri ) { $ this -> splitURI ( $ uri ) ; $ this -> connect ( ) ; if ( ! is_array ( $ this -> pclasses ) || count ( $ this -> pclasses ) == 0 ) { return ; } foreach ( $ this -> pclasses as $ pclasses ) { foreach ( $ pclasses as $ pclass ) { mysql_query ( "DELETE FROM `{$this->dbName}`.`{$this->dbT...
Save pclasses to database
234,032
public function clear ( $ uri ) { try { $ this -> splitURI ( $ uri ) ; unset ( $ this -> pclasses ) ; $ this -> connect ( ) ; mysql_query ( "DELETE FROM `{$this->dbName}`.`{$this->dbTable}`" , $ this -> link ) ; } catch ( Exception $ e ) { throw new Klarna_DatabaseException ( $ e -> getMessage ( ) , $ e -> getCode ( ) ...
Clear the pclasses
234,033
public function help ( ) { $ style = new Eurekon \ Style ( ' *** RUN - HELP ***' ) ; Eurekon \ Out :: std ( $ style -> color ( 'fg' , Eurekon \ Style :: COLOR_GREEN ) -> get ( ) ) ; Eurekon \ Out :: std ( '' ) ; $ help = new Eurekon \ Help ( '...' , true ) ; $ help -> addArgument ( '' , 'directory' , 'Config directory ...
Help method .
234,034
public function run ( ) { $ argument = Eurekon \ Argument :: getInstance ( ) ; $ directory = ( string ) $ argument -> get ( 'directory' ) ; $ configName = ( string ) $ argument -> get ( 'item' ) ; $ configNamespace = ( string ) $ argument -> get ( 'namespace' , null , 'global.database' ) ; $ dbName = ( string ) $ argum...
Run method .
234,035
protected function findConfigs ( $ currentFile , array $ data , $ configName = '' , $ doLoadJoins = false ) { $ configs = array ( ) ; $ data = $ this -> replace ( $ currentFile , $ data ) ; foreach ( $ data [ 'configs' ] as $ name => $ config ) { if ( ! empty ( $ configName ) && $ name !== $ configName ) { continue ; }...
Find configs .
234,036
protected function loadJoins ( $ currentFile , & $ config , $ data ) { if ( empty ( $ config [ 'joins' ] ) || ! is_array ( $ config [ 'joins' ] ) ) { $ config [ 'joins' ] = array ( ) ; return $ this ; } foreach ( $ config [ 'joins' ] as $ joinName => & $ joinConfig ) { $ filename = $ currentFile ; if ( isset ( $ joinCo...
Load joined configs .
234,037
protected function buildColRelVal ( $ where ) { $ rel = $ where [ 'rel' ] ; $ col = $ where [ 'col' ] ; $ val = $ where [ 'val' ] ; if ( $ rel == 'EQ' ) { $ val = $ this -> quote ( $ val ) ; $ rel = '=' ; } else { $ val = $ this -> formWhereVal ( $ val ) ; } $ col = $ this -> formWhereCol ( $ col ) ; $ where = trim ( "...
for normal case where condition like col = val
234,038
public function loadEnv ( ) { $ ed = $ this -> loadEnvDefault ( ) ; $ ej = $ this -> loadEnvJson ( ) ; if ( ! $ ed && ! $ ej ) { $ msg = "No configuration files found." ; $ this -> error ( $ msg ) ; die ( $ msg ) ; } }
loads env - default . json and then env . json
234,039
public function find ( ) { $ this -> getFileList ( ) -> clear ( ) ; foreach ( $ this -> searchLocations as $ location ) { if ( ! is_dir ( $ location ) ) { continue ; } $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ location ) ) ; foreach ( $ iterator as $ file ) { if ( ! $ this -> f...
Do the actual searching
234,040
public function filter ( \ SPLFileInfo $ file ) { foreach ( $ this -> filterlist as $ filter ) { if ( ! $ filter -> filter ( $ file ) ) { return false ; } } return true ; }
Filter the file
234,041
public function file ( $ name = '' , $ uploadDir = UPLOAD ) { if ( isset ( $ _FILES [ $ name ] ) ) { $ file = new FileUpload ( $ _FILES [ $ name ] , $ uploadDir ) ; return $ file ; } else { throw new FileNotUploadedException ( sprintf ( 'Your %s file is not uploaded yet' , $ name ) ) ; } }
upload a file with input name and uplaod dir
234,042
private function findDocumentRootInScriptFileName ( ) { $ filename = $ this -> server -> get ( 'SCRIPT_FILENAME' ) ? : false ; if ( false === $ filename ) { return false ; } $ parse = explode ( '/' , $ filename ) ; $ count = count ( $ parse ) ; if ( $ count && $ count > 1 ) { $ path = array_slice ( $ parse , 0 , $ coun...
find document root in server script filename
234,043
public function getBaseUri ( ) { if ( '' !== $ qs = $ this -> getQueryString ( ) ) { $ qs = '?' . $ qs ; } return $ this -> getSchemeAndHost ( ) . $ this -> getRequestUri ( ) . $ qs ; }
find the scheme and request uri
234,044
public function segment ( $ segment ) { $ segments = $ this -> segments ; return isset ( $ segments [ $ segment - 1 ] ) ? $ segments [ $ segment - 1 ] : false ; }
get url segment
234,045
public function inTimezone ( string $ timeZoneId ) : TimezonedDateTime { return new TimezonedDateTime ( \ DateTimeImmutable :: createFromFormat ( self :: DISPLAY_FORMAT , $ this -> format ( self :: DISPLAY_FORMAT ) , new \ DateTimeZone ( $ timeZoneId ) ) ) ; }
Returns the current date time as if it were in the supplied timezone
234,046
public function render ( ) : string { $ obLevel = ob_get_level ( ) ; ob_start ( ) ; extract ( $ this -> data ) ; $ templatesPath = $ this -> config -> projectPath . $ this -> config -> templatesPath ; $ package = '' ; $ template = $ this -> template ; if ( ! empty ( $ this -> section -> module ) ) { $ package = $ this ...
Generate output .
234,047
protected function findTemplate ( string $ templatesPath , string $ package , string $ templateName ) : string { if ( ! empty ( $ package ) ) { $ templatePath = $ templatesPath . $ this -> config -> templatesDefault . '/' . strtolower ( $ package ) . '/' . str_replace ( '.' , '/' , $ templateName ) . $ this -> extensio...
Find full path for requested template . Returned path may not exists .
234,048
public function withGlobalScope ( $ identifier , $ scope ) { $ this -> scopes [ $ identifier ] = $ scope ; if ( method_exists ( $ scope , 'extend' ) ) $ scope -> extend ( $ this ) ; return $ this ; }
Register a new global scope .
234,049
protected function whereCountQuery ( QueryBuilder $ query , $ operator = '>=' , $ count = 1 , $ boolean = 'and' ) { if ( is_numeric ( $ count ) ) { $ count = new Expression ( $ count ) ; } $ this -> query -> addBinding ( $ query -> getBindings ( ) , 'where' ) ; return $ this -> where ( new Expression ( '(' . $ query ->...
Add a sub query count clause to the query .
234,050
public function mergeModelDefinedRelationConstraints ( Builder $ relation ) { $ removedScopes = $ relation -> removedScopes ( ) ; $ relationQuery = $ relation -> getQuery ( ) ; return $ this -> withoutGlobalScopes ( $ removedScopes ) -> mergeWheres ( $ relationQuery -> wheres , $ relationQuery -> getBindings ( ) ) ; }
Merge the constraints from a relation query to the current query .
234,051
public function prePersist ( LifecycleEventArgs $ args ) : void { $ invitation = $ args -> getObject ( ) ; if ( ! $ invitation instanceof Invitation ) { return ; } $ event = $ invitation -> getEvent ( ) ; if ( $ event -> getAuthor ( ) == $ invitation -> getInvitee ( ) ) { $ invitation -> setResponse ( Invitation :: RES...
Checks the invitation author and accepts if they match .
234,052
protected function checkIfEntityExists ( ) { $ query = new ReadQuery ( $ this -> connection , $ this -> model , $ this -> factory , $ this -> accessor , $ this -> dispatcher ) ; foreach ( $ this -> model -> primaryFields ( ) as $ field ) { $ value = $ this -> accessor -> getPropertyValue ( $ this -> instance , $ field ...
Returns true if entity exists database
234,053
public function setMax ( $ max ) { if ( ! is_string ( $ max ) && ! is_numeric ( $ max ) ) { throw new Zend_Validate_Exception ( 'Invalid options to validator provided' ) ; } $ max = ( integer ) $ this -> _fromByteString ( $ max ) ; $ min = $ this -> getMin ( true ) ; if ( ( $ min !== null ) && ( $ max < $ min ) ) { thr...
Sets the maximum filesize
234,054
public function isValid ( & $ errors = null , $ throwException = false ) { $ descriptorSpec = array ( 0 => array ( 'pipe' , 'r' ) , 1 => array ( 'pipe' , 'w' ) , 2 => array ( 'pipe' , 'w' ) , ) ; $ process = proc_open ( 'php -l' , $ descriptorSpec , $ pipes ) ; if ( ! is_resource ( $ process ) ) { throw new \ Exception...
Run Php through lint checker
234,055
public static function varExport ( $ var , $ indent = 0 , $ dontIndentFirstLine = true ) { $ export = var_export ( $ var , true ) ; $ export = preg_replace ( '/^array \\(/' , 'array(' , $ export ) ; if ( $ export === 'NULL' ) { $ export = 'null' ; } $ export = str_replace ( ' ' , ' ' , $ export ) ; $ lines = explod...
Return a string which is a php - parsable representation of a variable
234,056
public static function exportVar ( $ value ) { $ closures = self :: collectClosures ( $ value ) ; $ res = var_export ( $ value , true ) ; if ( ! empty ( $ closures ) ) { $ subs = [ ] ; foreach ( $ closures as $ key => $ closure ) { $ subs [ "'" . $ key . "'" ] = self :: dumpClosure ( $ closure ) ; } $ res = strtr ( $ r...
Returns a parsable string representation of given value . In contrast to var_dump outputs Closures as PHP code .
234,057
private static function collectClosures ( & $ input ) { static $ closureNo = 1 ; $ closures = [ ] ; if ( is_array ( $ input ) ) { foreach ( $ input as & $ value ) { if ( is_array ( $ value ) || $ value instanceof Closure ) { $ closures = array_merge ( $ closures , self :: collectClosures ( $ value ) ) ; } } } elseif ( ...
Collects closures from given input . Substitutes closures with a tag .
234,058
protected function extractFieldLabels ( WriterFieldInterface ... $ fields ) : array { return array_map ( function ( WriterFieldInterface $ field ) : string { return $ field -> getLabel ( ) ; } , $ fields ) ; }
Extract labels from fields .
234,059
public function createVendor ( $ name = null ) { $ vendor = new $ this -> vendorFqcn ( $ name ) ; $ vendor -> setOrganization ( $ this -> oh -> getOrganization ( ) ) ; return $ vendor ; }
Create new Vendor
234,060
public function findVendorForName ( $ name ) { return $ this -> em -> getRepository ( $ this -> vendorFqcn ) -> findOneBy ( array ( 'name' => $ name , 'organization' => $ this -> oh -> getOrganization ( ) ) ) ; }
Find Vendor for name
234,061
public function findVendorForSlug ( $ slug ) { return $ this -> em -> getRepository ( $ this -> vendorFqcn ) -> findOneBy ( array ( 'slug' => $ slug , 'organization' => $ this -> oh -> getOrganization ( ) ) ) ; }
Find Vendor for slug
234,062
public function run ( array $ sources , array $ destinations ) { $ updatedSources = [ ] ; foreach ( $ sources as $ source ) { $ css = $ this -> getCacheDir ( ) . $ source -> getBasename ( '.scss' ) . '.css' ; $ this -> addNotification ( 'compiling ' . $ source . ' to ' . $ css ) ; $ process = new Process ( $ command = ...
Compile scss file into css file via compass .
234,063
public function checkRequirements ( ) { $ process = new Process ( $ this -> getBin ( ) . ' version' ) ; $ process -> run ( ) ; if ( ! $ process -> isSuccessful ( ) ) { throw new Exception ( 'compass is not found at ' . $ this -> getBin ( ) . '. ' . $ process -> getErrorOutput ( ) ) ; } }
Check that compass is installed and available .
234,064
protected function buildCommandString ( $ source ) { $ commandPattern = '%s %s %s %s %s' ; $ command = sprintf ( $ commandPattern , $ this -> getBin ( ) , 'compile' , $ source -> getRealPath ( ) , '--css-dir=' . $ this -> getCacheDir ( ) , '--sass-dir=' . $ source -> getPath ( ) ) ; return $ command ; }
Build the compass compile command line .
234,065
public function getColumn ( $ name , $ alias = '' ) { $ column = new DerivedColumn ( $ name , $ alias ) ; return $ column -> setTable ( $ this ) ; }
Returns a column object correlated to the current table .
234,066
public function getAllRecords ( ) { $ recordType = $ this -> getRecordType ( ) ; $ all = $ recordType :: get ( ) -> filterByCallBack ( function ( DataObject $ obj ) { return $ obj -> canView ( ) ; } ) ; return new PaginatedList ( $ all , $ this -> request ) ; }
Gets all the records and returns them paginated
234,067
public function getEditableRecords ( ) { $ recordType = $ this -> getRecordType ( ) ; $ all = $ recordType :: get ( ) -> filterByCallBack ( function ( DataObject $ obj ) { return $ obj -> canEdit ( ) ; } ) ; return new PaginatedList ( $ all , $ this -> request ) ; }
Gets all editable records and returns them paginated
234,068
public function create_new ( $ request ) { if ( ! $ this -> canCreate ( ) ) { return $ this -> httpError ( 403 , "You do not have permission to create new " . $ this -> getPluralName ( ) ) ; } $ this -> addCrumb ( 'Create new ' . $ this -> getSingularName ( ) ) ; return $ this -> customise ( [ 'Form' => $ this -> Creat...
URL method to create a new record
234,069
public function CreationForm ( ) { $ fields = singleton ( $ this -> getRecordType ( ) ) -> getFrontEndFields ( ) ; $ fields -> push ( new HiddenField ( 'ID' ) ) ; $ form = new Form ( $ this , 'CreationForm' , $ fields , new FieldList ( new FormAction ( 'doSave' , 'Save' ) , new FormAction ( 'doCancel' , 'Cancel' ) ) ) ...
Scaffolds a form for creating managed data types
234,070
public function doSave ( $ data , $ form ) { $ recordType = $ this -> getRecordType ( ) ; $ record = $ recordType :: create ( ) ; $ form -> saveInto ( $ record ) ; $ record -> write ( ) ; $ this -> redirect ( $ this -> Link ( ) ) ; }
Function for saving the form
234,071
public function AlphabetPages ( ) { $ query = new SQLSelect ( ) ; $ pages = new ArrayList ( ) ; $ sortOn = $ this -> config ( ) -> sort_on ; $ query -> select ( array ( "Left($sortOn, 1) AS Letter" ) ) ; $ query -> from ( $ this -> getRecordType ( ) ) ; $ query -> groupBy ( array ( 'Letter' ) ) ; $ lettersFound = $ que...
Generates a ArrayList of anonymous objects that can be used to create an alphabet menu for all the items linking only when there are items begining with the letter and providing an indication of whether it is currently selected or not
234,072
public function removeHandler ( IHandler $ handler = NULL ) { if ( NULL !== $ handler && $ this -> handler == $ handler ) { $ this -> handler = NULL ; } else { $ this -> handler = NULL ; } }
Remove a handler from the session .
234,073
private function readCsv ( $ fullPath ) { $ result = [ ] ; $ entries = $ this -> hlpCsv -> read ( $ fullPath ) ; foreach ( $ entries as $ one ) { $ i = 0 ; $ fromId = $ one [ $ i ++ ] ; $ fromName = $ one [ $ i ++ ] ; $ toId = $ one [ $ i ++ ] ; $ toName = $ one [ $ i ++ ] ; $ volume = $ one [ $ i ++ ] ; $ item = new D...
Read & parse CSV file .
234,074
public static function fromNative ( ) { $ args = func_get_args ( ) ; $ amount = new Integer ( $ args [ 0 ] ) ; $ currency = Currency :: fromNative ( $ args [ 1 ] ) ; return new static ( $ amount , $ currency ) ; }
Returns a Money object from native int amount and string currency code
234,075
public function sameValueAs ( ValueObjectInterface $ money ) { if ( false === Util :: classEquals ( $ this , $ money ) ) { return false ; } return $ this -> getAmount ( ) -> sameValueAs ( $ money -> getAmount ( ) ) && $ this -> getCurrency ( ) -> sameValueAs ( $ money -> getCurrency ( ) ) ; }
Tells whether two Currency are equal by comparing their amount and currency
234,076
public function add ( Integer $ quantity ) { $ amount = new Integer ( $ this -> getAmount ( ) -> toNative ( ) + $ quantity -> toNative ( ) ) ; $ result = new self ( $ amount , $ this -> getCurrency ( ) ) ; return $ result ; }
Add an integer quantity to the amount and returns a new Money object . Use a negative quantity for subtraction .
234,077
public function filterByPageId ( $ pageId = null , $ comparison = null ) { if ( is_array ( $ pageId ) ) { $ useMinMax = false ; if ( isset ( $ pageId [ 'min' ] ) ) { $ this -> addUsingAlias ( M2PTableMap :: COL_PAGE_ID , $ pageId [ 'min' ] , Criteria :: GREATER_EQUAL ) ; $ useMinMax = true ; } if ( isset ( $ pageId [ '...
Filter the query on the page_id column
234,078
public function usePageQuery ( $ relationAlias = null , $ joinType = Criteria :: INNER_JOIN ) { return $ this -> joinPage ( $ relationAlias , $ joinType ) -> useQuery ( $ relationAlias ? $ relationAlias : 'Page' , '\Attogram\SharedMedia\Orm\PageQuery' ) ; }
Use the Page relation Page object
234,079
public static function getInstance ( $ name ) { $ key = self :: _instanceKey ( $ name ) ; if ( ! isset ( self :: $ _instances [ $ key ] ) ) { $ dataSource = self :: getDataAdapter ( ) ; if ( is_null ( $ dataSource ) ) { $ data = array ( ) ; } else { $ data = $ dataSource -> load ( $ key ) ; } $ config = new self ( $ da...
Returns config instance
234,080
public static function newInstance ( $ name , $ data = null ) { if ( ! is_array ( $ data ) ) { $ data = array ( ) ; } $ config = self :: getInstance ( $ name ) ; $ config -> _data = $ data ; return $ config ; }
Shortcut for instance creation .
234,081
public static function clearInstance ( $ name ) { $ key = self :: _instanceKey ( $ name ) ; if ( isset ( self :: $ _instances [ $ key ] ) ) { unset ( self :: $ _instances [ $ key ] ) ; } }
Unloads config instance .
234,082
public static function clearAll ( ) { $ names = array_keys ( self :: $ _instances ) ; foreach ( $ names as $ name ) { self :: clearInstance ( $ name ) ; } }
Upload all configs data
234,083
public static function saveInstance ( $ name ) { $ adapter = self :: getDataAdapter ( ) ; if ( ! is_null ( $ adapter ) ) { $ config = self :: getInstance ( $ name ) ; $ key = self :: _instanceKey ( $ name ) ; $ result = $ adapter -> save ( $ key , $ config ) ; } else { $ result = false ; } return $ result ; }
Save config instance data
234,084
public static function deleteInstance ( $ name ) { $ adapter = self :: getDataAdapter ( ) ; if ( ! is_null ( $ adapter ) ) { $ key = self :: _instanceKey ( $ name ) ; $ result = $ adapter -> delete ( $ key ) ; } else { $ result = false ; } self :: clearInstance ( $ name ) ; return $ result ; }
Delete config instance data
234,085
static function instance ( \ hlin \ archetype \ Filesystem $ fs , array $ filemaps ) { $ i = new static ; $ i -> fs = $ fs ; $ i -> filemaps = $ filemaps ; return $ i ; }
Default filemaps will be used if none are specified .
234,086
public function get ( $ endpoint , $ params = [ ] ) { $ url = $ this -> domain . '/' . $ endpoint ; if ( ! empty ( $ params ) ) { $ url = $ url . '?' . http_build_query ( $ params ) ; } $ request = new Request ( $ url ) ; if ( isset ( $ this -> config [ 'secret' ] ) ) { $ request -> headers -> add ( [ 'X-Client-Secret'...
Make a GET Request to an endpoint
234,087
public function getEndpoint ( $ endpoint ) { $ endpoint = studly_case ( $ endpoint ) ; if ( ! array_key_exists ( $ endpoint , $ this -> endpoints ) ) { throw new InvalidEndpointException ( "Endpoint {$endpoint} does not exists" ) ; } $ class = $ this -> endpoints [ $ endpoint ] ; if ( isset ( $ this -> cachedEndpoints ...
Get an API endpoint .
234,088
public static function routes ( ) { Route :: name ( 'public::blog.' ) -> prefix ( 'blog' ) -> namespace ( '\\Arcanesoft\\Blog\\Http\\Controllers\\Front' ) -> group ( function ( ) { Routes \ PostsRoutes :: register ( ) ; Routes \ CategoriesRoutes :: register ( ) ; Routes \ TagsRoutes :: register ( ) ; } ) ; }
Register the public blog routes .
234,089
public static function find ( array $ query ) { $ pubs = Client :: get ( 'publication' , $ query ) ; return array_map ( function ( $ data ) { return new self ( $ data ) ; } , $ pubs ) ; }
Retrieve an array of Publication objects according to a search query .
234,090
private function transformToHtml ( $ data , $ hypertextRoutes = [ ] ) { $ hypertextHtml = $ this -> getHypertextHtml ( $ hypertextRoutes ) ; if ( ! is_array ( $ data ) ) { return "<p>{$data}</p>\n{$hypertextHtml}" ; } $ html = "<table style=\"border: 1px solid black;\">" ; foreach ( $ data as $ k => $ v ) { if ( is_arr...
Recursively converts the response into an html string . This is an html string with tables and underlying tables .
234,091
private function getHypertextHtml ( $ routes = [ ] ) { if ( ! $ routes ) { return '' ; } $ html = "<table style=\"border: 1px solid black;\">\n" ; foreach ( $ routes as $ name => $ route ) { $ html .= "<tr>\n" ; $ html .= "<td style=\"border: 1px solid black;\">rel: {$name}</td>\n" ; $ html .= "<td style=\"border: 1px ...
Generates the html for the hypertext routes .
234,092
public static function fromResource ( ResourceInterface $ resource , $ path ) { if ( $ resource instanceof FileResourceInterface ) { return $ resource ; } file_put_contents ( $ path , $ resource -> getStream ( ) ) ; $ attr = [ 'mimetype' => $ resource -> getMimetype ( ) , 'lastmodified' => $ resource -> getLastModified...
Converts any resource to a local resource .
234,093
static function FindContentRights ( Content $ content ) { $ result = null ; $ currContent = $ content ; do { $ result = $ currContent -> GetUserGroupRights ( ) ; $ currContent = ContentTreeUtil :: ParentOf ( $ currContent ) ; } while ( ! $ result && $ currContent ) ; if ( $ result ) { return $ result ; } return self ::...
Finds the content rigths by searching in element tree
234,094
static function FindPageRights ( Page $ page ) { $ currPage = $ page ; $ result = null ; do { $ result = $ currPage -> GetUserGroupRights ( ) ; $ currPage = $ currPage -> GetParent ( ) ; } while ( ! $ result && $ currPage ) ; if ( ! $ result && $ page -> GetSite ( ) ) { $ siteRights = $ page -> GetSite ( ) -> GetUserGr...
Gets the rights of the page
234,095
public static function hash ( $ data ) { if ( false === is_string ( $ data ) && false === is_numeric ( $ data ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string or number, "%s" given' , __METHOD__ , gettype ( $ data ) ) , E_USER_ERROR ) ; } return hash ( self :: HASH_ALGORITHM ...
Hashes text and returns it
234,096
public static function validateHash ( $ data , $ hash ) { if ( false === is_string ( $ data ) && false === is_numeric ( $ data ) ) { return trigger_error ( sprintf ( 'Argument 1 passed to %s() must be of the type string or number, "%s" given' , __METHOD__ , gettype ( $ data ) ) , E_USER_ERROR ) ; } if ( false === is_st...
Verifies that data matches a hash
234,097
private static function hash_equals ( $ expected , $ actual ) { $ expected = ( string ) $ expected ; $ actual = ( string ) $ actual ; if ( true === function_exists ( 'hash_equals' ) ) { return hash_equals ( $ expected , $ actual ) ; } $ lenExpected = mb_strlen ( $ expected , self :: ENCODING ) ; $ lenActual = mb_strlen...
Hash equals function for PHP 5 . 5 +
234,098
public static function decode ( $ string ) { if ( ! $ string ) { return new ArrayObject ( ) ; } $ array = SymfonyYaml :: parse ( $ string ) ; if ( ! is_array ( $ array ) ) { $ array = [ ] ; } return ArrayObject :: make ( $ array ) ; }
Convert a yaml string to an array .
234,099
public static function mime2ext ( $ mime ) { $ ext2mime = static :: get_mime_map ( ) ; $ mime2ext = array_flip ( $ ext2mime ) ; return ( isset ( $ mime2ext [ $ mime ] ) ) ? $ mime2ext [ $ mime ] : 'unknown' ; }
Get the file extension associated with a given mime type .