本文整理汇总了PHP中Helpers::CheckClassType方法的典型用法代码示例。如果您正苦于以下问题:PHP Helpers::CheckClassType方法的具体用法?PHP Helpers::CheckClassType怎么用?PHP Helpers::CheckClassType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helpers
的用法示例。
在下文中一共展示了Helpers::CheckClassType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadTargetModel
/**
* Loads Target Model for the Comment
* It needs to be a SiContentBehavior Object
*
* @return type
*/
private function loadTargetModel()
{
// Fast lane
if ($this->cachedLoadedTarget != null) {
return $this->cachedLoadedTarget;
}
// Request Params
$targetModelClass = Yii::app()->request->getParam('model');
$targetModelId = (int) Yii::app()->request->getParam('id');
$targetModelClass = Yii::app()->input->stripClean(trim($targetModelClass));
if ($targetModelClass == "" || $targetModelId == "") {
throw new CHttpException(500, Yii::t('CommentModule.controllers_CommentController', 'Model & Id Parameter required!'));
}
if (!Helpers::CheckClassType($targetModelClass, 'HActiveRecordContent')) {
throw new CHttpException(500, Yii::t('CommentModule.controllers_CommentController', 'Invalid target class given'));
}
$model = call_user_func(array($targetModelClass, 'model'));
$target = $model->findByPk($targetModelId);
if (!$target instanceof HActiveRecordContent) {
throw new CHttpException(500, Yii::t('CommentModule.controllers_CommentController', 'Invalid target class given'));
}
if ($target == null) {
throw new CHttpException(404, Yii::t('CommentModule.controllers_CommentController', 'Target not found!'));
}
// Check if we can read the target model, so we can comment it?
if (!$target->content->canRead(Yii::app()->user->id)) {
throw new CHttpException(403, Yii::t('CommentModule.controllers_CommentController', 'Access denied!'));
}
// Create Fastlane:
$this->cachedLoadedTarget = $target;
return $target;
}
示例2: init
public function init()
{
if (!Helpers::CheckClassType($this->parserClass, "cebe\\markdown\\Parser")) {
throw new CException("Invalid markdown parser class given!");
}
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/resources/highlight.js/highlight.pack.js');
Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl . '/resources/highlight.js/styles/' . $this->highlightJsCss . '.css');
Yii::app()->clientScript->registerScript("highlightJs", '$("pre code").each(function(i, e) { hljs.highlightBlock(e); });');
}
示例3: instantiate
protected function instantiate($attributes)
{
$className = $attributes['class'];
if (Helpers::CheckClassType($className, 'Notification')) {
// Instanciate correct Asset Model
$model = new $className(null);
return $model;
}
return null;
}
示例4: actionContent
/**
* Redirects to given HActiveRecordContent or HActiveRecordContentAddon
*/
public function actionContent()
{
$id = (int) Yii::app()->request->getParam('id', "");
$model = Yii::app()->request->getParam('model');
// Check given model
if (!Helpers::CheckClassType($model, array('HActiveRecordContent', 'HActiveRecordContentAddon'))) {
throw new CHttpException(404, Yii::t('WallModule.controllers_PermaController', 'Invalid model given!'));
}
$model = call_user_func(array($model, 'model'));
$object = $model->findByPk($id);
if ($object == null) {
throw new CHttpException(404, Yii::t('WallModule.controllers_PermaController', 'Could not find requested content!'));
}
$this->redirect($object->content->getUrl());
}
示例5: getTypeInstances
/**
* Returns an array of instances of all available field types.
*
* @return Array
*/
public static function getTypeInstances($profileField = null)
{
$types = array();
foreach (self::getFieldTypes() as $className => $title) {
if (Helpers::CheckClassType($className, 'ProfileFieldType')) {
$instance = new $className();
if ($profileField != null) {
$instance->profileField = $profileField;
// Seems current type, so try load data
if ($profileField->field_type_class == $className) {
$instance->load();
}
}
$types[] = $instance;
}
}
return $types;
}
示例6: actionContent
/**
* On given Content Class and id redirect the user to it.
*/
public function actionContent()
{
$content = Content::model()->findByAttributes(array('object_model' => Yii::app()->request->getParam('model'), 'object_id' => Yii::app()->request->getParam('id')));
if ($content != null) {
$url = $this->createUrl('WallEntry', array('id' => $content->getFirstWallEntryId()));
$this->redirect($url);
return;
}
$id = (int) Yii::app()->request->getParam('id', "");
$model = Yii::app()->request->getParam('model');
// Check given model
if (!Helpers::CheckClassType($model, 'HActiveRecord')) {
throw new CHttpException(404, Yii::t('WallModule.controllers_PermaController', 'Unknown content class!'));
}
$model = call_user_func(array($model, 'model'));
$object = $model->findByPk($id);
if ($object == null) {
throw new CHttpException(404, Yii::t('WallModule.controllers_PermaController', 'Could not find requested content!'));
}
$url = $this->createUrl('WallEntry', array('id' => $object->content->getFirstWallEntryId()));
$this->redirect($url);
}
示例7: getFieldType
/**
* Returns the ProfileFieldType Class for this Profile Field
*
* @return ProfileFieldType
*/
public function getFieldType()
{
if ($this->_fieldType != null) {
return $this->_fieldType;
}
if ($this->field_type_class != "" && Helpers::CheckClassType($this->field_type_class, 'ProfileFieldType')) {
$type = $this->field_type_class;
$this->_fieldType = new $type();
$this->_fieldType->setProfileField($this);
return $this->_fieldType;
}
return null;
}
示例8: loadContentAddon
/**
* Loads Content Addon
* We also validates that the content addon corresponds to the loaded content.
*
* @param string $className
* @param int $pk
*/
public function loadContentAddon($className, $pk)
{
if (!Helpers::CheckClassType($className, 'HActiveRecordContentAddon')) {
throw new CException("Given className is not a content addon model!");
}
$model = call_user_func(array($className, 'model'));
$target = $model->findByPk($pk);
if ($target === null) {
throw new CHttpException(500, 'Could not find content addon record!');
}
if ($target->object_model != get_class($this->parentContent) && $target->object_id != $this->parentContent->getPrimaryKey()) {
throw new CHttpException(500, 'Content addon not belongs to given content record!');
}
$this->contentAddon = $target;
}