idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
5,600
protected function renderItems ( ) { $ lines = array ( ) ; if ( $ this -> type === Enum :: DROPDOWN_CONTENT ) { $ lines [ ] = $ this -> dropdownContent ; } if ( $ this -> type === Enum :: DROPDOWN_LIST ) { foreach ( $ this -> items as $ item ) { if ( is_string ( $ item ) ) { $ lines [ ] = $ item ; continue ; } if ( ! isset ( $ item [ 'label' ] ) ) { throw new InvalidConfigException ( "The 'label' option is required." ) ; } $ label = $ this -> encodeLabels ? \ CHtml :: encode ( $ item [ 'label' ] ) : $ item [ 'label' ] ; $ options = ArrayHelper :: getValue ( $ item , 'options' , array ( ) ) ; $ linkOptions = ArrayHelper :: getValue ( $ item , 'linkOptions' , array ( ) ) ; $ linkOptions [ 'tabindex' ] = '-1' ; $ content = \ CHtml :: link ( $ label , ArrayHelper :: getValue ( $ item , 'url' , '#' ) , $ linkOptions ) ; $ lines [ ] = \ CHtml :: tag ( 'li' , $ options , $ content ) ; } } return \ CHtml :: tag ( 'ul' , $ this -> htmlOptions , implode ( "\n" , $ lines ) ) ; }
Renders dropdown items
5,601
public static function valid_fingerprint ( $ fingerprint = null , $ name = null ) { return Manager :: create ( $ name ) -> valid_fingerprint ( $ fingerprint ) ; }
Check if the given fingerprint or the default fingerprint parameter matches the curent session fingerprint .
5,602
public static function set ( $ key , $ value , $ manager = null ) { return Manager :: create ( $ manager ) -> set ( $ key , $ value ) ; }
Set a value on the session
5,603
public static function add ( $ key , $ value , $ manager = null ) { return Manager :: create ( $ manager ) -> add ( $ key , $ value ) ; }
Similar to add but forces the element to be an array and appends an item .
5,604
public static function doDeleteAll ( PropelPDO $ con = null ) { if ( $ con === null ) { $ con = Propel :: getConnection ( UserCustomerRelationPeer :: DATABASE_NAME , Propel :: CONNECTION_WRITE ) ; } $ affectedRows = 0 ; try { $ con -> beginTransaction ( ) ; $ affectedRows += BasePeer :: doDeleteAll ( UserCustomerRelationPeer :: TABLE_NAME , $ con , UserCustomerRelationPeer :: DATABASE_NAME ) ; UserCustomerRelationPeer :: clearInstancePool ( ) ; UserCustomerRelationPeer :: clearRelatedInstancePool ( ) ; $ con -> commit ( ) ; return $ affectedRows ; } catch ( Exception $ e ) { $ con -> rollBack ( ) ; throw $ e ; } }
Deletes all rows from the user_customer_relation table .
5,605
public static function doDelete ( $ values , PropelPDO $ con = null ) { if ( $ con === null ) { $ con = Propel :: getConnection ( UserCustomerRelationPeer :: DATABASE_NAME , Propel :: CONNECTION_WRITE ) ; } if ( $ values instanceof Criteria ) { UserCustomerRelationPeer :: clearInstancePool ( ) ; $ criteria = clone $ values ; } elseif ( $ values instanceof UserCustomerRelation ) { UserCustomerRelationPeer :: removeInstanceFromPool ( $ values ) ; $ criteria = $ values -> buildPkeyCriteria ( ) ; } else { $ criteria = new Criteria ( UserCustomerRelationPeer :: DATABASE_NAME ) ; $ criteria -> add ( UserCustomerRelationPeer :: ID , ( array ) $ values , Criteria :: IN ) ; foreach ( ( array ) $ values as $ singleval ) { UserCustomerRelationPeer :: removeInstanceFromPool ( $ singleval ) ; } } $ criteria -> setDbName ( UserCustomerRelationPeer :: DATABASE_NAME ) ; $ affectedRows = 0 ; try { $ con -> beginTransaction ( ) ; $ affectedRows += BasePeer :: doDelete ( $ criteria , $ con ) ; UserCustomerRelationPeer :: clearRelatedInstancePool ( ) ; $ con -> commit ( ) ; return $ affectedRows ; } catch ( Exception $ e ) { $ con -> rollBack ( ) ; throw $ e ; } }
Performs a DELETE on the database given a UserCustomerRelation or Criteria object OR a primary key value .
5,606
public static function retrieveByPK ( $ pk , PropelPDO $ con = null ) { if ( null !== ( $ obj = UserCustomerRelationPeer :: getInstanceFromPool ( ( string ) $ pk ) ) ) { return $ obj ; } if ( $ con === null ) { $ con = Propel :: getConnection ( UserCustomerRelationPeer :: DATABASE_NAME , Propel :: CONNECTION_READ ) ; } $ criteria = new Criteria ( UserCustomerRelationPeer :: DATABASE_NAME ) ; $ criteria -> add ( UserCustomerRelationPeer :: ID , $ pk ) ; $ v = UserCustomerRelationPeer :: doSelect ( $ criteria , $ con ) ; return ! empty ( $ v ) > 0 ? $ v [ 0 ] : null ; }
Retrieve a single object by pkey .
5,607
public static function retrieveByPKs ( $ pks , PropelPDO $ con = null ) { if ( $ con === null ) { $ con = Propel :: getConnection ( UserCustomerRelationPeer :: DATABASE_NAME , Propel :: CONNECTION_READ ) ; } $ objs = null ; if ( empty ( $ pks ) ) { $ objs = array ( ) ; } else { $ criteria = new Criteria ( UserCustomerRelationPeer :: DATABASE_NAME ) ; $ criteria -> add ( UserCustomerRelationPeer :: ID , $ pks , Criteria :: IN ) ; $ objs = UserCustomerRelationPeer :: doSelect ( $ criteria , $ con ) ; } return $ objs ; }
Retrieve multiple objects by pkey .
5,608
public function setSettingValue ( $ key , $ value ) { if ( $ key == '_orientation' && $ value == 'landscape' ) { $ this -> setLandscape ( ) ; } elseif ( $ key == '_orientation' && is_null ( $ value ) ) { $ this -> setPortrait ( ) ; } elseif ( $ key == '_borderSize' ) { $ this -> setBorderSize ( $ value ) ; } elseif ( $ key == '_borderColor' ) { $ this -> setBorderColor ( $ value ) ; } else { $ this -> $ key = $ value ; } }
Set Setting Value
5,609
public function setLandscape ( ) { $ this -> _orientation = 'landscape' ; $ this -> _pageSizeW = $ this -> _defaultPageSizeH ; $ this -> _pageSizeH = $ this -> _defaultPageSizeW ; }
Set Landscape Orientation
5,610
public function setPortrait ( ) { $ this -> _orientation = null ; $ this -> _pageSizeW = $ this -> _defaultPageSizeW ; $ this -> _pageSizeH = $ this -> _defaultPageSizeH ; }
Set Portrait Orientation
5,611
public function getBorderSize ( ) { $ t = $ this -> getBorderTopSize ( ) ; $ l = $ this -> getBorderLeftSize ( ) ; $ r = $ this -> getBorderRightSize ( ) ; $ b = $ this -> getBorderBottomSize ( ) ; return array ( $ t , $ l , $ r , $ b ) ; }
Get Border Size
5,612
public function setBorderColor ( $ pValue = null ) { $ this -> _borderTopColor = $ pValue ; $ this -> _borderLeftColor = $ pValue ; $ this -> _borderRightColor = $ pValue ; $ this -> _borderBottomColor = $ pValue ; }
Set Border Color
5,613
public function getBorderColor ( ) { $ t = $ this -> getBorderTopColor ( ) ; $ l = $ this -> getBorderLeftColor ( ) ; $ r = $ this -> getBorderRightColor ( ) ; $ b = $ this -> getBorderBottomColor ( ) ; return array ( $ t , $ l , $ r , $ b ) ; }
Get Border Color
5,614
public function getRepository ( string $ className ) : AbstractObjectRepository { $ className = 'Infakt\\Repository\\' . substr ( $ className , strrpos ( $ className , '\\' ) + 1 ) . 'Repository' ; if ( ! class_exists ( $ className ) ) { throw new LogicException ( "There is no repository to work with class $className." ) ; } return new $ className ( $ this ) ; }
Return object repository for a specific model class name .
5,615
public function get ( string $ query ) : ResponseInterface { return $ this -> client -> request ( 'get' , $ this -> buildQuery ( $ query ) , [ 'headers' => $ this -> getAuthorizationHeader ( ) ] ) ; }
Send HTTP GET request .
5,616
private function registerSanitizer ( ) { $ this -> singleton ( Contracts \ Sanitizer :: class , function ( $ app ) { $ config = $ app [ 'config' ] ; return new Factory ( $ config -> get ( 'sanitizer.filters' ) ) ; } ) ; $ this -> singleton ( 'arcanedev.sanitizer' , Contracts \ Sanitizer :: class ) ; }
Register Helpers .
5,617
public function hook ( OutputInterface $ output , array $ response ) { $ this -> printBoolean ( $ output , 'OK' , $ response [ 'success' ] , true === $ response [ 'success' ] ) ; }
output for hook api .
5,618
public function delete ( OutputInterface $ output , array $ response ) { $ this -> printBoolean ( $ output , 'OK' , $ response [ 'success' ] , true === $ response [ 'success' ] ) ; }
output for delete api .
5,619
protected function matchUser ( $ email , $ group ) { return Credentials :: getUserProvider ( ) -> findByLogin ( $ email ) -> addGroup ( Credentials :: getGroupProvider ( ) -> findByName ( $ group ) ) ; }
Add the user by email to a group .
5,620
public static function prefixFromType ( $ strType ) { switch ( $ strType ) { case Type :: ARRAY_TYPE : return "obj" ; case Type :: BOOLEAN : return "bln" ; case Type :: DATE_TIME : return "dtt" ; case Type :: FLOAT : return "flt" ; case Type :: INTEGER : return "int" ; case Type :: OBJECT : return "obj" ; case Type :: STRING : return "str" ; } return "" ; }
Returns prefix for variable according to variable type
5,621
public function getInstalledTemplatePaths ( ) { $ dir = QCUBED_CONFIG_DIR . '/templates' ; $ paths = [ ] ; if ( $ dir !== false ) { foreach ( scandir ( $ dir ) as $ strFileName ) { if ( substr ( $ strFileName , - 8 ) == '.inc.php' ) { $ paths2 = include ( $ dir . '/' . $ strFileName ) ; if ( $ paths2 && is_array ( $ paths2 ) ) { $ paths = array_merge ( $ paths , $ paths2 ) ; } } } } return $ paths ; }
Return an array of paths to template files . This base class versions searches a config directory for pointers to template files to use . This allows qcubed repos to inject templates into the codegen process .
5,622
public static function getSettingsXml ( ) { $ strCrLf = "\r\n" ; $ strToReturn = sprintf ( '<codegen>%s' , $ strCrLf ) ; $ strToReturn .= sprintf ( ' <name application="%s"/>%s' , Codegen :: $ ApplicationName , $ strCrLf ) ; $ strToReturn .= sprintf ( ' <render preferredRenderMethod="%s"/>%s' , Codegen :: $ PreferredRenderMethod , $ strCrLf ) ; $ strToReturn .= sprintf ( ' <dataSources>%s' , $ strCrLf ) ; foreach ( Codegen :: $ CodeGenArray as $ objCodeGen ) { $ strToReturn .= $ strCrLf . $ objCodeGen -> getConfigXml ( ) ; } $ strToReturn .= sprintf ( '%s </dataSources>%s' , $ strCrLf , $ strCrLf ) ; $ strToReturn .= '</codegen>' ; return $ strToReturn ; }
Gets the settings in codegen_settings . xml file and returns its text without comments
5,623
public static function run ( $ strSettingsXmlFilePath ) { if ( ! defined ( 'QCUBED_CODE_GENERATING' ) ) { define ( 'QCUBED_CODE_GENERATING' , true ) ; } Codegen :: $ CodeGenArray = array ( ) ; Codegen :: $ SettingsFilePath = $ strSettingsXmlFilePath ; if ( ! file_exists ( $ strSettingsXmlFilePath ) ) { Codegen :: $ RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $ strSettingsXmlFilePath . ') was not found.' ; return ; } if ( ! is_file ( $ strSettingsXmlFilePath ) ) { Codegen :: $ RootErrors = 'FATAL ERROR: CodeGen Settings XML File (' . $ strSettingsXmlFilePath . ') was not found.' ; return ; } try { $ errorHandler = new Error \ Handler ( '\\QCubed\\Codegen\\QcubedHandleCodeGenParseError' , E_ALL ) ; Codegen :: $ SettingsXml = new \ SimpleXMLElement ( file_get_contents ( $ strSettingsXmlFilePath ) ) ; $ errorHandler -> restore ( ) ; } catch ( \ Exception $ objExc ) { Codegen :: $ RootErrors .= 'FATAL ERROR: Unable to parse CodeGenSettings XML File: ' . $ strSettingsXmlFilePath ; Codegen :: $ RootErrors .= "\r\n" ; Codegen :: $ RootErrors .= $ objExc -> getMessage ( ) ; return ; } Codegen :: $ ApplicationName = Codegen :: lookupSetting ( Codegen :: $ SettingsXml , 'name' , 'application' ) ; Codegen :: $ PreferredRenderMethod = Codegen :: lookupSetting ( Codegen :: $ SettingsXml , 'formgen' , 'preferredRenderMethod' ) ; Codegen :: $ CreateMethod = Codegen :: lookupSetting ( Codegen :: $ SettingsXml , 'formgen' , 'createMethod' ) ; Codegen :: $ DefaultButtonClass = Codegen :: lookupSetting ( Codegen :: $ SettingsXml , 'formgen' , 'buttonClass' ) ; if ( ! Codegen :: $ DefaultButtonClass ) { Codegen :: $ RootErrors .= "CodeGen Settings XML Fatal Error: buttonClass was not defined\r\n" ; return ; } if ( Codegen :: $ SettingsXml -> dataSources -> asXML ( ) ) { foreach ( Codegen :: $ SettingsXml -> dataSources -> children ( ) as $ objChildNode ) { switch ( dom_import_simplexml ( $ objChildNode ) -> nodeName ) { case 'database' : Codegen :: $ CodeGenArray [ ] = new DatabaseCodeGen ( $ objChildNode ) ; break ; case 'restService' : Codegen :: $ CodeGenArray [ ] = new RestServiceCodeGen ( $ objChildNode ) ; break ; default : Codegen :: $ RootErrors .= sprintf ( "Invalid Data Source Type in CodeGen Settings XML File (%s): %s\r\n" , $ strSettingsXmlFilePath , dom_import_simplexml ( $ objChildNode ) -> nodeName ) ; break ; } } } }
The function which actually performs the steps for code generation Code generation begins here .
5,624
protected function getTemplateSettings ( $ strTemplateFilePath , & $ strTemplate = null ) { if ( $ strTemplate === null ) { $ strTemplate = file_get_contents ( $ strTemplateFilePath ) ; } $ strError = 'Template\'s first line must be <template OverwriteFlag="boolean" TargetDirectory="string" DirectorySuffix="string" TargetFileName="string"/>: ' . $ strTemplateFilePath ; $ intPosition = strpos ( $ strTemplate , "\n" ) ; if ( $ intPosition === false ) { throw new \ Exception ( $ strError ) ; } $ strFirstLine = trim ( substr ( $ strTemplate , 0 , $ intPosition ) ) ; $ objTemplateXml = null ; try { @ $ objTemplateXml = new \ SimpleXMLElement ( $ strFirstLine ) ; } catch ( \ Exception $ objExc ) { } if ( is_null ( $ objTemplateXml ) || ( ! ( $ objTemplateXml instanceof \ SimpleXMLElement ) ) ) { throw new \ Exception ( $ strError ) ; } $ strTemplate = substr ( $ strTemplate , $ intPosition + 1 ) ; return $ objTemplateXml ; }
Returns the settings of the template file as SimpleXMLElement object
5,625
public function generateFile ( $ strModuleSubPath , $ strTemplateFilePath , $ mixArgumentArray , $ blnSave = true ) { if ( Codegen :: DEBUG_MODE ) { echo ( "Evaluating $strTemplateFilePath<br/>" ) ; } if ( ! file_exists ( $ strTemplateFilePath ) ) { throw new Caller ( 'Template File Not Found: ' . $ strTemplateFilePath ) ; } $ a = array ( ) ; foreach ( static :: $ TemplatePaths as $ strTemplatePath ) { array_unshift ( $ a , $ strTemplatePath . $ strModuleSubPath ) ; } $ strSearchPath = implode ( PATH_SEPARATOR , $ a ) . PATH_SEPARATOR . get_include_path ( ) ; $ strOldIncludePath = set_include_path ( $ strSearchPath ) ; if ( $ strSearchPath != get_include_path ( ) ) { throw new Caller ( 'Can\'t override include path. Make sure your apache or server settings allow include paths to be overridden. ' ) ; } $ strTemplate = $ this -> evaluatePHP ( $ strTemplateFilePath , $ mixArgumentArray , $ templateSettings ) ; set_include_path ( $ strOldIncludePath ) ; $ blnOverwriteFlag = Type :: cast ( $ templateSettings [ 'OverwriteFlag' ] , Type :: BOOLEAN ) ; $ strTargetDirectory = Type :: cast ( $ templateSettings [ 'TargetDirectory' ] , Type :: STRING ) ; $ strDirectorySuffix = Type :: cast ( $ templateSettings [ 'DirectorySuffix' ] , Type :: STRING ) ; $ strTargetFileName = Type :: cast ( $ templateSettings [ 'TargetFileName' ] , Type :: STRING ) ; if ( is_null ( $ blnOverwriteFlag ) || is_null ( $ strTargetFileName ) || is_null ( $ strTargetDirectory ) || is_null ( $ strDirectorySuffix ) ) { throw new \ Exception ( 'the template settings cannot be null' ) ; } if ( $ blnSave && $ strTargetDirectory ) { $ strTargetDirectory = $ strTargetDirectory . $ strDirectorySuffix ; if ( ! is_dir ( $ strTargetDirectory ) ) { if ( ! Folder :: makeDirectory ( $ strTargetDirectory , 0777 ) ) { throw new \ Exception ( 'Unable to mkdir ' . $ strTargetDirectory ) ; } } $ strFilePath = sprintf ( '%s/%s' , $ strTargetDirectory , $ strTargetFileName ) ; if ( $ blnOverwriteFlag || ( ! file_exists ( $ strFilePath ) ) ) { $ intBytesSaved = file_put_contents ( $ strFilePath , $ strTemplate ) ; $ this -> setGeneratedFilePermissions ( $ strFilePath ) ; return ( $ intBytesSaved == strlen ( $ strTemplate ) ) ; } else { return true ; } } if ( $ blnSave ) { return true ; } return $ strTemplate ; }
Generates a php code using a template file
5,626
protected function evaluatePHP ( $ strFilename , $ mixArgumentArray , & $ templateSettings = null ) { if ( $ mixArgumentArray ) { foreach ( $ mixArgumentArray as $ strName => $ mixValue ) { $ $ strName = $ mixValue ; } } global $ _TEMPLATE_SETTINGS ; unset ( $ _TEMPLATE_SETTINGS ) ; $ _TEMPLATE_SETTINGS = null ; $ objCodeGen = $ this ; $ strEscapeIdentifierBegin = \ QCubed \ Database \ Service :: getDatabase ( $ this -> intDatabaseIndex ) -> EscapeIdentifierBegin ; $ strEscapeIdentifierEnd = \ QCubed \ Database \ Service :: getDatabase ( $ this -> intDatabaseIndex ) -> EscapeIdentifierEnd ; $ strAlreadyRendered = ob_get_contents ( ) ; if ( ob_get_level ( ) ) { ob_clean ( ) ; } ob_start ( ) ; include ( $ strFilename ) ; $ strTemplate = ob_get_contents ( ) ; ob_end_clean ( ) ; $ templateSettings = $ _TEMPLATE_SETTINGS ; unset ( $ _TEMPLATE_SETTINGS ) ; print ( $ strAlreadyRendered ) ; $ strTemplate = str_replace ( "\r" , '' , $ strTemplate ) ; return $ strTemplate ; }
Returns the evaluated PHP
5,627
protected function modelClassName ( $ strTableName ) { $ strTableName = $ this -> stripPrefixFromTable ( $ strTableName ) ; return sprintf ( '%s%s%s' , $ this -> strClassPrefix , QString :: camelCaseFromUnderscore ( $ strTableName ) , $ this -> strClassSuffix ) ; }
Given a table name returns the name of the class for the corresponding model object .
5,628
public function modelVariableName ( $ strTableName ) { $ strTableName = $ this -> stripPrefixFromTable ( $ strTableName ) ; return Codegen :: prefixFromType ( Type :: OBJECT ) . QString :: camelCaseFromUnderscore ( $ strTableName ) ; }
Given a table name returns a variable name that will be used to represent the corresponding model object .
5,629
protected function modelColumnVariableName ( SqlColumn $ objColumn ) { return Codegen :: prefixFromType ( $ objColumn -> VariableType ) . QString :: camelCaseFromUnderscore ( $ objColumn -> Name ) ; }
Given a column returns the name of the variable used to represent the column s value inside the model object .
5,630
protected function modelReferenceColumnName ( $ strColumnName ) { $ intNameLength = strlen ( $ strColumnName ) ; if ( ( $ intNameLength > 3 ) && ( substr ( $ strColumnName , $ intNameLength - 3 ) == "_id" ) ) { $ strColumnName = substr ( $ strColumnName , 0 , $ intNameLength - 3 ) ; } else { $ strColumnName = sprintf ( "%s_object" , $ strColumnName ) ; } return $ strColumnName ; }
Given the name of a column that is a foreign key to another table returns a kind of virtual column name that would refer to the object pointed to . This new name is used to refer to the object version of the column by json and other encodings and derivatives of this name are used to represent a variable and property name that refers to this object that will get stored in the model .
5,631
protected function modelReferenceVariableName ( $ strColumnName ) { $ strColumnName = $ this -> modelReferenceColumnName ( $ strColumnName ) ; return Codegen :: prefixFromType ( Type :: OBJECT ) . QString :: camelCaseFromUnderscore ( $ strColumnName ) ; }
Given a column name to a foreign key returns the name of the variable that will represent the foreign object stored in the model .
5,632
public static function modelConnectorControlName ( ColumnInterface $ objColumn ) { if ( ( $ o = $ objColumn -> Options ) && isset ( $ o [ 'Name' ] ) ) { return $ o [ 'Name' ] ; } return QString :: wordsFromCamelCase ( Codegen :: modelConnectorPropertyName ( $ objColumn ) ) ; }
Returns the control label name as used in the ModelConnector corresponding to this column or table .
5,633
public static function modelConnectorPropertyName ( ColumnInterface $ objColumn ) { if ( $ objColumn instanceof SqlColumn ) { if ( $ objColumn -> Reference ) { return $ objColumn -> Reference -> PropertyName ; } else { return $ objColumn -> PropertyName ; } } elseif ( $ objColumn instanceof ReverseReference ) { if ( $ objColumn -> Unique ) { return ( $ objColumn -> ObjectDescription ) ; } else { return ( $ objColumn -> ObjectDescriptionPlural ) ; } } elseif ( $ objColumn instanceof ManyToManyReference ) { return $ objColumn -> ObjectDescriptionPlural ; } else { throw new \ Exception ( 'Unknown column type.' ) ; } }
The property name used in the ModelConnector for the given column virtual column or table
5,634
public function modelConnectorVariableName ( ColumnInterface $ objColumn ) { $ strPropName = static :: modelConnectorPropertyName ( $ objColumn ) ; $ objControlHelper = $ this -> getControlCodeGenerator ( $ objColumn ) ; return $ objControlHelper -> varName ( $ strPropName ) ; }
Return a variable name corresponding to the given column including virtual columns like ReverseReference and QManyToMany references .
5,635
public function modelConnectorLabelVariableName ( ColumnInterface $ objColumn ) { $ strPropName = static :: modelConnectorPropertyName ( $ objColumn ) ; return \ QCubed \ Codegen \ Generator \ Label :: instance ( ) -> varName ( $ strPropName ) ; }
Returns a variable name for the label version of a control which would be the read - only version of viewing the data in the column .
5,636
public static function dataListControlName ( SqlTable $ objTable ) { if ( ( $ o = $ objTable -> Options ) && isset ( $ o [ 'Name' ] ) ) { return $ o [ 'Name' ] ; } return QString :: wordsFromCamelCase ( $ objTable -> ClassNamePlural ) ; }
Returns the control label name as used in the data list panel corresponding to this column .
5,637
public static function dataListItemName ( SqlTable $ objTable ) { if ( ( $ o = $ objTable -> Options ) && isset ( $ o [ 'ItemName' ] ) ) { return $ o [ 'ItemName' ] ; } return QString :: wordsFromCamelCase ( $ objTable -> ClassName ) ; }
Returns the name of an item in the data list as will be displayed in the edit panel .
5,638
protected function variableTypeFromDbType ( $ strDbType ) { switch ( $ strDbType ) { case Database \ FieldType :: BIT : return Type :: BOOLEAN ; case Database \ FieldType :: BLOB : return Type :: STRING ; case Database \ FieldType :: CHAR : return Type :: STRING ; case Database \ FieldType :: DATE : return Type :: DATE_TIME ; case Database \ FieldType :: DATE_TIME : return Type :: DATE_TIME ; case Database \ FieldType :: FLOAT : return Type :: FLOAT ; case Database \ FieldType :: INTEGER : return Type :: INTEGER ; case Database \ FieldType :: TIME : return Type :: DATE_TIME ; case Database \ FieldType :: VAR_CHAR : return Type :: STRING ; case Database \ FieldType :: JSON : return Type :: STRING ; default : throw new \ Exception ( "Invalid Db Type to Convert: $strDbType" ) ; } }
Returns the variable type corresponding to the database column type
5,639
protected function pluralize ( $ strName ) { switch ( true ) { case ( strtolower ( $ strName ) == 'play' ) : return $ strName . 's' ; } $ intLength = strlen ( $ strName ) ; if ( substr ( $ strName , $ intLength - 1 ) == "y" ) { return substr ( $ strName , 0 , $ intLength - 1 ) . "ies" ; } if ( substr ( $ strName , $ intLength - 1 ) == "s" ) { return $ strName . "es" ; } if ( substr ( $ strName , $ intLength - 1 ) == "x" ) { return $ strName . "es" ; } if ( substr ( $ strName , $ intLength - 1 ) == "z" ) { return $ strName . "zes" ; } if ( substr ( $ strName , $ intLength - 2 ) == "sh" ) { return $ strName . "es" ; } if ( substr ( $ strName , $ intLength - 2 ) == "ch" ) { return $ strName . "es" ; } return $ strName . "s" ; }
Return the plural of the given name . Override this and return the plural version of particular names if this generic version isn t working for you .
5,640
public function toArray ( ) { $ attr = ! empty ( $ this -> getWarden ( ) ) ? $ this -> getWarden ( ) : null ; if ( empty ( $ attr ) ) { $ attr = empty ( $ this -> getVisible ( ) ) ? $ this -> getFillable ( ) : $ this -> getVisible ( ) ; } $ returnable = [ ] ; $ f_model = \ FormModel :: using ( 'plain' ) -> withModel ( $ this ) ; foreach ( $ attr as $ old => $ new ) { if ( ! empty ( $ relations = $ f_model -> getRelationalDataAndModels ( $ this , $ old ) ) ) { $ returnable [ $ new ] = $ relations ; } if ( stripos ( $ old , '_id' ) !== false ) { if ( ! empty ( $ this -> $ new ) ) { $ returnable [ $ new ] = $ relations ; } } else { if ( isset ( $ this -> $ old ) ) { $ returnable [ $ new ] = $ this -> $ old ; } } } return $ returnable ; }
Parses the warden config .
5,641
public function cc ( $ email , $ name = null ) { if ( ! is_array ( $ email ) ) { $ email = array ( $ email => $ name ) ; } foreach ( $ email as $ address => $ name ) { if ( is_numeric ( $ address ) && is_string ( $ name ) ) { $ this -> cc [ $ name ] = null ; } else { $ this -> cc [ $ address ] = $ name ; } } return $ this ; }
Add Carbon copies
5,642
public function send ( ) { $ config = \ CCConfig :: create ( 'mail' ) ; if ( $ config -> disabled === true ) { return ; } if ( empty ( $ this -> to ) ) { throw new Exception ( "Cannot send mail without recipients." ) ; } if ( $ config -> get ( 'catch_all.enabled' ) === true ) { $ mail = clone $ this ; $ mail -> to = array ( ) ; $ mail -> cc = array ( ) ; $ mail -> bcc = array ( ) ; $ mail -> to ( $ config -> get ( 'catch_all.addresses' ) ) ; return $ mail -> transport ( $ config -> get ( 'catch_all.transporter' ) ) ; } $ this -> transport ( ) ; }
Prepare the message for sending to the transport
5,643
protected function transport ( $ transporter = null ) { if ( ! is_null ( $ transporter ) ) { $ transporter = Transporter :: create ( $ transporter ) ; } else { $ transporter = $ this -> transporter ; } $ transporter -> send ( $ this ) ; }
Transport the message
5,644
public function returnExceptionToThrow ( $ status_code ) { static $ map = array ( 1 => 'E4xx_IndexOutOfBoundsWebDriverError' , 2 => 'E4xx_NoCollectionWebDriverError' , 3 => 'E4xx_NoStringWebDriverError' , 4 => 'E4xx_NoStringLengthWebDriverError' , 5 => 'E4xx_NoStringWrapperWebDriverError' , 6 => 'E4xx_NoSuchDriverWebDriverError' , 7 => 'E4xx_NoSuchElementWebDriverError' , 8 => 'E4xx_NoSuchFrameWebDriverError' , 9 => 'E5xx_UnknownCommandWebDriverError' , 10 => 'E4xx_ObsoleteElementWebDriverError' , 11 => 'E4xx_ElementNotDisplayedWebDriverError' , 12 => 'E5xx_InvalidElementStateWebDriverError' , 13 => 'E5xx_UnhandledWebDriverError' , 14 => 'E4xx_ExpectedWebDriverError' , 15 => 'E4xx_ElementNotSelectableWebDriverError' , 16 => 'E4xx_NoSuchDocumentWebDriverError' , 17 => 'E5xx_UnexpectedJavascriptWebDriverError' , 18 => 'E4xx_NoScriptResultWebDriverError' , 19 => 'E4xx_XPathLookupWebDriverError' , 20 => 'E4xx_NoSuchCollectionWebDriverError' , 21 => 'E4xx_TimeOutWebDriverError' , 22 => 'E5xx_NullPointerWebDriverError' , 23 => 'E4xx_NoSuchWindowWebDriverError' , 24 => 'E4xx_InvalidCookieDomainWebDriverError' , 25 => 'E4xx_UnableToSetCookieWebDriverError' , 26 => 'E4xx_UnexpectedAlertOpenWebDriverError' , 27 => 'E4xx_NoAlertOpenWebDriverError' , 28 => 'E4xx_ScriptTimeoutWebDriverError' , 29 => 'E4xx_InvalidElementCoordinatesWebDriverError' , 30 => 'E4xx_IMENotAvailableWebDriverError' , 31 => 'E5xx_IMEEngineActivationFailedWebDriverError' , 32 => 'E4xx_InvalidSelectorWebDriverError' , 33 => 'E5xx_SessionNotCreatedWebDriverError' , 34 => 'E4xx_MoveTargetOutOfBoundsWebDriverError' , ) ; if ( $ status_code == 0 ) { return null ; } if ( isset ( $ map [ $ status_code ] ) ) { return __NAMESPACE__ . '\\' . $ map [ $ status_code ] ; } return __NAMESPACE__ . '\\UnknownWebDriverError' ; }
Returns the name of the exception class to throw
5,645
private function getHttpVerb ( $ webdriver_command ) { $ methods = $ this -> getMethods ( ) ; if ( ! isset ( $ methods [ $ webdriver_command ] ) ) { throw new E5xx_BadMethodCallWebDriverError ( sprintf ( '%s is not a valid webdriver command.' , $ webdriver_command ) ) ; } return $ methods [ $ webdriver_command ] ; }
determine the HTTP verb to use for a given webdriver command
5,646
public function getProjectRoot ( $ name , $ mode = Project :: MODE_SRC ) { if ( $ mode === Project :: MODE_PHAR ) { $ root = new Dir ( PHAR_ROOT ) ; } elseif ( ( $ proot = $ this -> hostConfig -> get ( array ( 'projects' , $ name , 'root' ) ) ) != NULL ) $ root = new Dir ( $ proot ) ; else $ root = $ this -> getProjectsRoot ( ) -> sub ( $ name . '/Umsetzung/' ) ; return $ root ; }
Macht keine Checks ob das Projekt existiert
5,647
private function parseName ( string $ name ) : array { $ name = str_replace ( '/' , '\\' , $ name ) ; if ( strpos ( $ name , '\\' ) !== false ) { $ names = explode ( '\\' , $ name ) ; $ class = array_pop ( $ names ) ; return [ join ( '\\' , $ names ) , $ class ] ; } return [ '' , $ name ] ; }
Split user name into namespace and class name .
5,648
private function getGalleryList ( Response $ response ) { $ list = $ this -> manager -> getGalleryList ( ) ; foreach ( $ list as $ gallery ) { $ file = $ this -> prepareGallery ( $ gallery ) ; $ response -> addFile ( $ file ) ; $ response -> addTreeFile ( $ file ) ; } }
get Gallery list .
5,649
private function getGallery ( Response $ response , $ target = '' ) { if ( $ target && $ gallery = $ this -> manager -> getGallery ( basename ( $ target ) ) ) { $ response -> setCwd ( $ this -> prepareGallery ( $ gallery ) ) ; $ images = $ gallery -> getImages ( true ) ; foreach ( $ images as $ img ) { $ this -> addImages ( $ response , $ img , $ this -> driverOptions [ 'rootName' ] . DIRECTORY_SEPARATOR . basename ( $ target ) ) ; } } }
get Gallery .
5,650
private function prepareGallery ( Gallery $ gallery ) { $ time = $ gallery -> getUpdatedAt ( ) ? $ gallery -> getUpdatedAt ( ) -> getTimestamp ( ) : time ( ) ; $ file = new FileInfo ( $ gallery -> getName ( ) , $ this -> driverId , $ time , $ this -> driverOptions [ 'rootName' ] ) ; $ file -> setHash ( $ this -> getDriverId ( ) . '_' . FileInfo :: encode ( $ this -> driverOptions [ 'rootName' ] . DIRECTORY_SEPARATOR . $ gallery -> getId ( ) ) ) ; return $ file ; }
prepare Gallery .
5,651
private function addImage ( Response $ response , Image $ image , $ galleryId , $ imageSize ) { if ( $ image -> get ( $ imageSize ) ) { $ href = $ image -> get ( $ imageSize ) -> getHref ( ) ; $ file = new FileInfo ( $ image -> getTitle ( ) . '(' . $ imageSize . ')' , $ this -> getDriverId ( ) , $ image -> getUpdateAt ( ) -> getTimestamp ( ) , $ galleryId ) ; $ file -> setMime ( 'image/jpeg' ) ; $ file -> setTmb ( $ image -> get ( $ this -> driverOptions [ 'thumbSize' ] ) -> getHref ( ) ) ; $ file -> setUrl ( $ href ) ; $ file -> setPath ( $ href ) ; $ response -> addFile ( $ file ) ; } }
add Image .
5,652
static public function getVirtualAlias ( $ strName ) { $ strName = trim ( $ strName ) ; $ strName = str_replace ( " " , "_" , $ strName ) ; $ strName = strtolower ( $ strName ) ; return $ strName ; }
Converts a virtual attribute name to an alias used in the query . The name is converted to an identifier that will work on any SQL database . In the query itself the name will have two underscores in front of the alias name to prevent conflicts with column names .
5,653
public static function extractSelectClause ( $ objClauses ) { if ( $ objClauses instanceof Clause \ Select ) { return $ objClauses ; } if ( is_array ( $ objClauses ) ) { $ hasSelects = false ; $ objSelect = QQ :: select ( ) ; foreach ( $ objClauses as $ objClause ) { if ( $ objClause instanceof Clause \ Select ) { $ hasSelects = true ; $ objSelect -> merge ( $ objClause ) ; } } if ( ! $ hasSelects ) { return null ; } return $ objSelect ; } return null ; }
Searches for all the Clause \ Select clauses and merges them into one clause and returns that clause . Returns null if none found .
5,654
static public function func ( $ strName , $ param1 ) { $ args = func_get_args ( ) ; $ strFunc = array_shift ( $ args ) ; return new Node \ FunctionNode ( $ strFunc , $ args ) ; }
Apply an arbitrary scalar function using the given parameters . See below for functions that let you apply common SQL functions . The list below only includes sql operations that are generic to all supported versions of SQL . However you can call Func directly with any named function that works in your current SQL version knowing that it might not be cross platform compatible if you ever change SQL engines .
5,655
static public function mathOp ( $ strOperation , $ param1 ) { $ args = func_get_args ( ) ; $ strFunc = array_shift ( $ args ) ; return new Node \ Math ( $ strFunc , $ args ) ; }
Apply an arbitrary math operation to 2 or more operands . Operands can be scalar values or column nodes .
5,656
protected function registerBladeDirectives ( ) { Blade :: directive ( 'form' , function ( $ expression ) { $ expression = $ this -> addParenthesis ( $ expression ) ; return "<?php app('Activisme_BE')->model{$expression}; ?>" ; } ) ; Blade :: directive ( 'input' , function ( $ expression ) { $ expression = $ this -> addParenthesis ( $ expression ) ; return "<?php echo app('Activisme_BE')->input{$expression}; ?>" ; } ) ; Blade :: directive ( 'text' , function ( $ expression ) { $ expression = $ this -> addParenthesis ( $ expression ) ; return "<?php echo app('Activisme_BE')->text{$expression}; ?>" ; } ) ; Blade :: directive ( 'checkbox' , function ( $ expression ) { $ expression = $ this -> addParenthesis ( $ expression ) ; return "<?php echo app('Activisme_BE')->checkbox{$expression}; ?>" ; } ) ; Blade :: directive ( 'radio' , function ( $ expression ) { $ expression = $ this -> addParenthesis ( $ expression ) ; return "<?php echo app('Activisme_BE')->radio{$expression}; ?>" ; } ) ; Blade :: directive ( 'options' , function ( $ expression ) { $ expression = $ this -> addParenthesis ( $ expression ) ; return "<?php echo app('Activisme_BE')->options{$expression}; ?>" ; } ) ; Blade :: directive ( 'error' , function ( $ expression ) { $ expression = $ this -> addParenthesis ( $ expression ) ; return "<?php echo app('Activisme_BE')->error{$expression}; ?>" ; } ) ; }
Register blade directives .
5,657
public function setStyleValue ( $ key , $ value ) { if ( $ key == '_borderSize' ) { $ this -> setBorderSize ( $ value ) ; } elseif ( $ key == '_borderColor' ) { $ this -> setBorderColor ( $ value ) ; } else { $ this -> $ key = $ value ; } }
Set style value
5,658
public function getUser ( $ username , $ password ) { $ authHash = $ this -> hashUserNameAndPassword ( $ username , $ password ) ; $ body = json_encode ( [ 'clientType' => 'wp-plugin' ] ) ; try { $ response = $ this -> client -> post ( $ this -> loginurl , [ 'headers' => [ 'Authorization' => 'Basic ' . $ authHash ] , 'verify' => $ this -> certFile , 'body' => $ body ] ) ; $ this -> response = $ response -> getBody ( ) ; } catch ( ClientException $ e ) { $ response = [ 'code' => $ e -> getCode ( ) , 'response' => $ e -> getMessage ( ) , 'error' => true ] ; $ this -> response = json_encode ( $ response ) ; } catch ( ConnectException $ e ) { $ message = 'Can not connect to Leadpages Server:' ; $ response = $ this -> parseException ( $ e , $ message ) ; $ this -> response = $ response ; } return $ this ; }
get user information
5,659
public function createApiKey ( ) { if ( ! isset ( $ this -> token ) ) { return false ; } $ authHeader = 'LP-Security-Token' ; if ( stripos ( $ this -> token , 'lp ' ) === 0 ) { $ authHeader = 'Authorization' ; } try { $ response = $ this -> client -> post ( $ this -> keyUrl , [ 'headers' => [ $ authHeader => $ this -> token , 'Content-Type' => 'application/json' , ] , 'verify' => $ this -> certFile , 'body' => json_encode ( [ 'label' => 'wordpress-plugin' ] ) , ] ) ; $ body = json_decode ( $ response -> getBody ( ) , true ) ; $ value = false ; if ( array_key_exists ( 'value' , $ body ) ) { $ value = $ body [ 'value' ] ; } } catch ( ClientException $ e ) { $ value = false ; } catch ( ConnectException $ e ) { $ value = false ; } return $ value ; }
Create an API key for account
5,660
public function parseResponse ( $ deleteTokenOnFail = false ) { $ responseArray = json_decode ( $ this -> response , true ) ; if ( isset ( $ responseArray [ 'error' ] ) && $ responseArray [ 'error' ] ) { unset ( $ this -> token ) ; if ( $ deleteTokenOnFail ) { $ this -> deleteToken ( ) ; } return $ this -> response ; } $ this -> token = $ responseArray [ 'securityToken' ] ; return 'success' ; }
Parse response for call to Leadpages Login . If response does not contain a error we will return a response with HttpResponseCode and Message
5,661
protected static function detectType ( array $ data ) { foreach ( [ self :: TYPE_MESSAGE , self :: TYPE_EDITED_MESSAGE , self :: TYPE_CHANNEL_POST , self :: TYPE_EDITED_CHANNEL_POST , self :: TYPE_INLINE_QUERY , self :: TYPE_CHOSEN_INLINE_RESULT , self :: TYPE_CALLBACK_QUERY , ] as $ type ) { if ( isset ( $ data [ $ type ] ) ) { return $ type ; } } return static :: TYPE_UNKNOWN ; }
Detects update type
5,662
public function perform ( ) { if ( ! is_null ( $ this -> input ) ) { CCIn :: instance ( $ this -> input ) ; } else { CCIn :: instance ( CCServer :: instance ( ) ) ; } static :: $ _current = & $ this ; if ( ! $ this -> route instanceof CCRoute ) { $ this -> route = CCRouter :: resolve ( '#404' ) ; } foreach ( CCRouter :: events_matching ( 'wake' , $ this -> route -> uri ) as $ callback ) { if ( ( $ return = CCContainer :: call ( $ callback ) ) instanceof CCResponse ) { $ this -> response = $ return ; return $ this ; } } if ( ! is_array ( $ this -> route -> callback ) && is_callable ( $ this -> route -> callback ) ) { ob_start ( ) ; $ return = call_user_func_array ( $ this -> route -> callback , $ this -> route -> params ) ; $ output = ob_get_clean ( ) ; if ( ! $ return instanceof CCResponse ) { $ return = CCResponse :: create ( $ output ) ; } } elseif ( is_callable ( $ this -> route -> callback ) ) { $ return = call_user_func_array ( $ this -> route -> callback , array ( $ this -> route -> action , $ this -> route -> params ) ) ; if ( ! $ return instanceof CCResponse ) { $ return = CCResponse :: create ( ( string ) $ return ) ; } } else { $ return = CCResponse :: error ( 404 ) ; } $ this -> response = $ return ; foreach ( CCRouter :: events_matching ( 'sleep' , $ this -> route -> uri ) as $ callback ) { if ( $ return = CCContainer :: call ( $ callback , $ this -> response ) instanceof CCResponse ) { $ this -> response = $ return ; return $ this ; } } return $ this ; }
Execute the Request
5,663
public function cardInfo ( $ number , $ expirationDate , $ code ) { $ this -> setArgument ( 'card_number' , $ number ) ; $ this -> setArgument ( 'card_expiration_date' , $ expirationDate ) ; return $ this -> setArgument ( 'card_code' , $ code ) ; }
Set card information .
5,664
public function address ( $ streetAddress , $ city , $ state , $ zip , $ country ) { $ this -> setArgument ( 'address' , $ streetAddress ) ; $ this -> setArgument ( 'city' , $ city ) ; $ this -> setArgument ( 'state' , $ state ) ; $ this -> setArgument ( 'zip' , $ zip ) ; return $ this -> setArgument ( 'country' , $ country ) ; }
Set card billing address .
5,665
private function createChainArrayOfReturnValues ( $ action , $ response ) { $ methods = $ this -> methods ; $ firstMethod = array_pop ( $ methods ) ; $ lastValue = $ response ; $ mockClassType = get_class ( $ this -> mockClass ) ; if ( ! $ this -> mockClass instanceof MockInterface ) { throw self :: generateException ( 'Class is not implementing MockInterface.' ) ; } $ mockClassInstanceId = $ this -> mockClass -> getShortifyPunitInstanceId ( ) ; foreach ( $ methods as $ currentMethod ) { $ fakeClass = new MockClassOnTheFly ( ) ; $ chainedMethodsBefore = $ this -> extractChainedMethodsBefore ( array_reverse ( $ this -> methods ) , $ currentMethod ) ; $ this -> addChainedMethodResponse ( $ chainedMethodsBefore , $ currentMethod , $ action , $ lastValue , $ mockClassInstanceId ) ; $ currentMethodName = key ( $ currentMethod ) ; $ fakeClass -> $ currentMethodName = function ( ) use ( $ mockClassInstanceId , $ mockClassType , $ chainedMethodsBefore , $ currentMethod ) { return ShortifyPunit :: createChainResponse ( $ mockClassInstanceId , $ mockClassType , $ chainedMethodsBefore , $ currentMethod , func_get_args ( ) ) ; } ; $ lastValue = $ fakeClass ; $ action = MockAction :: RETURNS ; } $ whenCase = new WhenCase ( $ mockClassType , $ this -> mockClass -> getShortifyPunitInstanceId ( ) , key ( $ firstMethod ) ) ; $ whenCase -> setMethod ( current ( $ firstMethod ) , $ action , $ lastValue ) ; }
Creating a chain array of return values
5,666
private function extractChainedMethodsBefore ( $ methods , $ currentMethod ) { $ chainedMethodsBefore = [ ] ; $ currentMethodName = key ( $ currentMethod ) ; foreach ( $ methods as $ method ) { $ methodName = key ( $ method ) ; if ( $ methodName == $ currentMethodName ) { break ; } $ chainedMethodsBefore [ ] = $ method ; } return $ chainedMethodsBefore ; }
Extracting chained methods before current method into an array
5,667
public function addChild ( & $ node , $ setCurrent = false ) { JLog :: add ( 'JTree::addChild() is deprecated.' , JLog :: WARNING , 'deprecated' ) ; $ this -> _current -> addChild ( $ node ) ; if ( $ setCurrent ) { $ this -> _current = & $ node ; } }
Method to add a child
5,668
public function getParent ( ) { JLog :: add ( 'JTree::getParent() is deprecated.' , JLog :: WARNING , 'deprecated' ) ; $ this -> _current = & $ this -> _current -> getParent ( ) ; }
Method to get the parent
5,669
public function addNamespace ( $ name ) { if ( ! Arr :: in ( $ name , self :: $ _namespace ) ) { self :: $ _namespace [ ] = $ name ; return true ; } return false ; }
Add new helper group namespace .
5,670
protected function _register ( $ id , $ className ) { $ id = ( string ) $ id ; if ( class_exists ( $ className ) ) { self :: $ _loaded [ $ id ] = $ className ; $ this [ $ id ] = function ( ) use ( $ className ) { return new $ className ( ) ; } ; } else { throw new Exception ( "Helper \"{{$className}}\" not found!" ) ; } }
Register helper class .
5,671
protected function _getClassName ( $ class ) { $ class = Str :: low ( $ class ) ; list ( $ plugin , $ className ) = pluginSplit ( $ class ) ; $ return = self :: HELPER_SUFFIX . '\\' . Inflector :: camelize ( $ className ) . self :: HELPER_SUFFIX ; if ( $ plugin !== null ) { return Inflector :: camelize ( $ plugin ) . '\\' . $ return ; } return Configure :: read ( 'App.namespace' ) . '\\' . $ return ; }
Get current helper class name .
5,672
public function createSlug ( $ value , $ id = 0 ) { $ slug = str_slug ( $ value ) ; $ relatedSlugs = $ this -> getRelatedSlugs ( $ slug , $ id ) ; if ( ! $ relatedSlugs -> contains ( 'slug' , $ slug ) ) { return $ slug ; } $ completed = false ; $ i = 1 ; while ( $ completed == false ) { $ newSlug = $ slug . '-' . $ i ; if ( ! $ relatedSlugs -> contains ( 'slug' , $ newSlug ) ) { return $ newSlug ; } $ i ++ ; } return $ slug ; }
Create a unique slug
5,673
protected function getRelatedSlugs ( $ slug , $ id = 0 ) { return $ this -> select ( 'slug' ) -> where ( 'slug' , 'like' , $ slug . '%' ) -> where ( 'id' , '<>' , $ id ) -> get ( ) ; }
Get similar slugs
5,674
public function setUser ( User $ v = null ) { if ( $ v === null ) { $ this -> setUserId ( NULL ) ; } else { $ this -> setUserId ( $ v -> getId ( ) ) ; } $ this -> aUser = $ v ; if ( $ v !== null ) { $ v -> addUserRole ( $ this ) ; } return $ this ; }
Declares an association between this object and a User object .
5,675
public function getUser ( PropelPDO $ con = null , $ doQuery = true ) { if ( $ this -> aUser === null && ( $ this -> user_id !== null ) && $ doQuery ) { $ this -> aUser = UserQuery :: create ( ) -> findPk ( $ this -> user_id , $ con ) ; } return $ this -> aUser ; }
Get the associated User object
5,676
public function setRole ( Role $ v = null ) { if ( $ v === null ) { $ this -> setRoleId ( NULL ) ; } else { $ this -> setRoleId ( $ v -> getId ( ) ) ; } $ this -> aRole = $ v ; if ( $ v !== null ) { $ v -> addUserRole ( $ this ) ; } return $ this ; }
Declares an association between this object and a Role object .
5,677
public function getRole ( PropelPDO $ con = null , $ doQuery = true ) { if ( $ this -> aRole === null && ( $ this -> role_id !== null ) && $ doQuery ) { $ this -> aRole = RoleQuery :: create ( ) -> findPk ( $ this -> role_id , $ con ) ; } return $ this -> aRole ; }
Get the associated Role object
5,678
final protected function initPostTypesTrait ( ) { add_action ( "init" , function ( ) { $ postTypes = $ this -> getPostTypes ( ) ; foreach ( $ postTypes as $ postType ) { $ this -> registerPostType ( $ postType ) ; } } ) ; }
Called automatically when the plugins are loaded this method registers our post types for the users of this boilerplate .
5,679
public function onUpdated ( UpdatedEvent $ event ) { if ( $ event -> getPackage ( ) -> getType ( ) == self :: PLUGIN_TYPE ) { $ this -> addPackage ( $ event -> getPackage ( ) ) ; } }
Update plugin data .
5,680
public function onInstalled ( InstalledEvent $ event ) { if ( $ event -> getPackage ( ) -> getType ( ) == self :: PLUGIN_TYPE ) { $ this -> addPackage ( $ event -> getPackage ( ) ) ; } }
Registr plugin .
5,681
protected function addPackage ( ComposerPackage $ package ) { $ plugin = $ this -> rep -> find ( $ package -> getName ( ) ) ; if ( ! $ plugin ) { $ plugin = new Plugin ( ) ; $ plugin -> setName ( $ package -> getName ( ) ) ; } list ( $ vendor , $ package ) = explode ( '/' , $ plugin -> getName ( ) ) ; try { $ data = $ this -> client -> getPlugin ( $ vendor , $ package ) ; $ plugin -> setTitle ( $ data [ 'title' ] ) -> setDescription ( $ data [ 'description' ] ) ; if ( $ data [ 'logo' ] ) { $ this -> downloader -> entity ( $ data [ 'logo' ] , $ plugin , true ) ; } } catch ( \ Exception $ e ) { } $ this -> em -> persist ( $ plugin ) ; $ this -> em -> flush ( ) ; }
Add plugin from package .
5,682
public function onRemoved ( RemovedEvent $ event ) { if ( $ event -> getPackage ( ) -> getType ( ) == self :: PLUGIN_TYPE ) { $ plugin = $ this -> rep -> find ( $ event -> getPackage ( ) -> getName ( ) ) ; if ( $ plugin ) { $ this -> em -> remove ( $ plugin ) ; $ this -> em -> flush ( ) ; } } }
Unregistr plugin .
5,683
public function onInstalledConfigureShmop ( InstalledEvent $ event ) { if ( $ event -> getPackage ( ) -> getName ( ) == self :: PACKAGE_SHMOP ) { $ this -> parameters -> set ( 'cache_time_keeper.driver' , 'cache_time_keeper.driver.multi' ) ; $ this -> parameters -> set ( 'cache_time_keeper.driver.multi.fast' , 'cache_time_keeper.driver.shmop' ) ; } }
Configure shmop .
5,684
public function onRemovedShmop ( RemovedEvent $ event ) { if ( $ event -> getPackage ( ) -> getName ( ) == self :: PACKAGE_SHMOP ) { $ this -> parameters -> set ( 'cache_time_keeper.driver' , 'cache_time_keeper.driver.file' ) ; } }
Restore config on removed shmop .
5,685
public function lock ( ) { if ( ! $ this -> isLocked ( ) ) { $ file = fopen ( $ this -> getFilePath ( ) , 'w' ) ; if ( $ file ) { fwrite ( $ file , getmypid ( ) ) ; fclose ( $ file ) ; return true ; } } return false ; }
Try create semafor file
5,686
protected function buildCommand ( $ binary , $ host , $ port , $ base ) { $ binary = $ this -> handleCustomIni ( $ binary ) ; $ base = str_replace ( "'" , '' , $ base ) ; $ command = "{$binary} -S {$host}:{$port} {$base}/server.php" ; return $ command ; }
Returns a command to pass through to shell .
5,687
protected function handleCustomIni ( $ command ) { if ( ! $ this -> option ( 'ini' ) ) { return $ command ; } $ command = str_replace ( "'" , '' , $ command ) ; $ iniPath = ( $ this -> option ( 'ini-path' ) === $ this -> defaultIniPath ) ? $ this -> laravel -> basePath ( ) . '/' . $ this -> defaultIniPath : $ this -> option ( 'ini-path' ) ; $ iniPath = realpath ( $ iniPath ) ; $ this -> info ( 'Loading custom configuration file: ' . $ iniPath , 'v' ) ; if ( ! file_exists ( $ iniPath ) ) { $ this -> warn ( sprintf ( 'File %s does not exist. Custom configuration will not be loaded.' , $ iniPath ) ) ; } $ command .= ' -c ' . $ iniPath ; return $ command ; }
Adds parameter telling PHP built - in server to respect a custom php . ini file .
5,688
public function getChoices ( $ username = null , $ email = null , $ or = false , $ limit = null ) { $ qb = $ this -> getRepository ( ) -> createQueryBuilder ( 'u' ) ; $ qb -> orderBy ( 'u.username' ) ; $ method = $ or ? 'orWhere' : 'andWhere' ; if ( $ username ) { $ qb -> $ method ( 'u.username LIKE :username' ) ; $ qb -> setParameter ( 'username' , '%' . $ username . '%' ) ; } if ( $ email ) { $ qb -> $ method ( 'u.email LIKE :email' ) ; $ qb -> setParameter ( 'email' , '%' . $ email . '%' ) ; } if ( $ limit ) { $ qb -> setMaxResults ( $ limit ) ; } return $ qb -> getQuery ( ) -> getResult ( ) ; }
Find user choices
5,689
public function getChoicesAsEmailUsername ( array & $ choices ) { $ ret = [ ] ; foreach ( $ choices as $ item ) { $ ret [ ] = sprintf ( '%s (%s)' , $ item -> getEmail ( ) , $ item -> getUsername ( ) ) ; } return $ ret ; }
Get selector choices as combined username + email
5,690
public function updateUser ( User $ user , UserUpdater $ up ) { $ up -> updateUser ( $ user , $ this -> getEncoder ( ) ) ; $ em = $ this -> getRegistry ( ) -> getManager ( ) ; $ em -> persist ( $ user ) ; $ em -> flush ( ) ; }
Update user details
5,691
public function get ( ) { if ( ! file_exists ( $ this -> file ) ) return array ( ) ; $ data = unserialize ( base64_decode ( file_get_contents ( $ this -> file ) ) ) ; return $ data ? : array ( ) ; }
returns the cached access token
5,692
public function put ( $ accessToken ) { if ( $ accessToken === null ) return unlink ( $ this -> file ) ; file_put_contents ( $ this -> file , base64_encode ( serialize ( $ accessToken ) ) ) ; return file_exists ( $ this -> file ) ; }
store the access token
5,693
public static function _fetch_handler ( & $ query ) { $ query -> fetch_arguments = array ( 'obj' ) ; return static :: assign ( $ query -> handler -> fetch ( $ query -> build ( ) , $ query -> handler -> builder ( ) -> parameters , array ( 'assoc' ) ) ) ; }
Fetch from the databse and created models out of the reults
5,694
public static function find ( $ param = null , $ param2 = null ) { $ settings = static :: _model ( ) ; $ query = DB :: select ( $ settings [ 'table' ] ) ; if ( ! is_null ( $ settings [ 'find_modifier' ] ) ) { $ callbacks = $ settings [ 'find_modifier' ] ; if ( ! \ CCArr :: is_collection ( $ callbacks ) ) { $ callbacks = array ( $ callbacks ) ; } foreach ( $ callbacks as $ call ) { if ( is_callable ( $ call ) ) { call_user_func_array ( $ call , array ( & $ query ) ) ; } else { throw new ModelException ( "Invalid Callback given to find modifiers." ) ; } } } if ( ! is_null ( $ param ) ) { if ( is_callable ( $ param ) && ! is_string ( $ param ) ) { call_user_func_array ( $ param , array ( & $ query ) ) ; } elseif ( is_null ( $ param2 ) ) { $ query -> where ( $ settings [ 'table' ] . '.' . $ settings [ 'primary_key' ] , $ param ) -> limit ( 1 ) ; } elseif ( ! is_null ( $ param2 ) ) { $ query -> where ( $ param , $ param2 ) -> limit ( 1 ) ; } } $ query -> forward_key ( $ settings [ 'primary_key' ] ) ; $ query -> fetch_arguments = array ( 'assoc' ) ; return static :: assign ( $ query -> run ( ) ) ; }
Model finder This function allows you direct access to your records .
5,695
public function __call_property ( $ key ) { $ result = parent :: __call_property ( $ key ) ; if ( $ result instanceof Model_Relation ) { return $ this -> _data_store [ $ key ] = $ result -> run ( ) ; } return $ result ; }
Call a function as a property
5,696
protected function has_one ( $ model , $ foreign_key = null , $ local_key = null ) { return new Model_Relation_HasOne ( $ this , $ model , $ foreign_key , $ local_key ) ; }
Has one releationships
5,697
protected function has_many ( $ model , $ foreign_key = null , $ local_key = null ) { return new Model_Relation_HasMany ( $ this , $ model , $ foreign_key , $ local_key ) ; }
Has many releationships
5,698
protected function belongs_to ( $ model , $ foreign_key = null , $ local_key = null ) { return new Model_Relation_BelongsTo ( $ this , $ model , $ foreign_key , $ local_key ) ; }
Belongs To releationships
5,699
public static function with ( $ with , $ callback = null ) { if ( ! is_array ( $ with ) ) { $ with = array ( $ with ) ; } $ settings = static :: _model ( ) ; $ query = DB :: select ( $ settings [ 'table' ] ) ; if ( ! is_null ( $ callback ) ) { call_user_func_array ( $ callback , array ( & $ query ) ) ; } $ query -> forward_key ( $ settings [ 'primary_key' ] ) ; $ query -> fetch_arguments = array ( 'assoc' ) ; $ results = static :: assign ( $ query -> run ( ) ) ; $ singleton = false ; if ( ! is_array ( $ results ) ) { $ results = array ( $ results ) ; $ singleton = true ; } $ ref_object = reset ( $ results ) ; asort ( $ with ) ; foreach ( $ with as $ relation => $ callback ) { if ( is_int ( $ relation ) && is_string ( $ callback ) ) { $ relation = $ callback ; $ callback = null ; } if ( strpos ( $ relation , '.' ) !== false ) { $ relation_layers = explode ( '.' , $ relation ) ; $ relation_name = array_pop ( $ relation_layers ) ; $ relation_collection = array ( ) ; foreach ( $ results as $ key => & $ item ) { $ curr_item = $ item ; foreach ( $ relation_layers as $ layer ) { $ curr_item = $ curr_item -> raw ( $ layer ) ; } $ relation_collection [ ] = $ curr_item ; } $ ref_object = reset ( $ relation_collection ) ; $ relation_object = call_user_func ( array ( $ ref_object , $ relation_name ) ) ; if ( $ relation_object instanceof Model_Relation ) { $ relation_object -> collection_assign ( $ relation_name , $ relation_collection , $ callback ) ; } } else { $ relation_object = call_user_func ( array ( $ ref_object , $ relation ) ) ; if ( $ relation_object instanceof Model_Relation ) { $ relation_object -> collection_assign ( $ relation , $ results , $ callback ) ; } } } if ( $ singleton ) { return reset ( $ results ) ; } return $ results ; }
find with an relationship