/**
  * @param Market_PaymentMethodRecord|array $values
  *
  * @return BaseModel
  */
 public static function populateModel($values)
 {
     /** @var self $model */
     $model = parent::populateModel($values);
     if (is_object($values)) {
         $model->settings = $values->settings;
     } else {
         $model->settings = $values['settings'];
     }
     return $model;
 }
 /**
  * Returns an array of variables to be used by the index or settings templates
  *
  * @param bool $includeLogs
  * @return array
  */
 public function getTemplateVariables($includeLogs = false)
 {
     $plugin = craft()->plugins->getPlugin('spamguard');
     $settings = $this->pluginSettings->getAttributes();
     $variables = array();
     $variables['name'] = $plugin->getName(true);
     $variables['alias'] = $plugin->getName();
     $variables['version'] = $plugin->getVersion();
     $variables['developer'] = $plugin->getDeveloper();
     $variables['developerUrl'] = $plugin->getDeveloperUrl();
     $variables['settings'] = $settings;
     if ($includeLogs) {
         $variables['logs'] = $this->getLogs();
     }
     return $variables;
 }
Ejemplo n.º 3
0
 /**
  * Populate blocktype.
  *
  * @param BaseModel $blockType
  * @param array     $blockTypeDef
  */
 protected function populateBlockType(BaseModel $blockType, array $blockTypeDef)
 {
     $fieldFactory = $this->getFieldFactory();
     $blockTypeFields = [];
     foreach ($blockType->getFields() as $blockTypeField) {
         $blockTypeFields[$blockTypeField->handle] = $blockTypeField;
     }
     $newBlockTypeFields = [];
     foreach ($blockTypeDef['fields'] as $blockTypeFieldHandle => $blockTypeFieldDef) {
         $blockTypeField = array_key_exists($blockTypeFieldHandle, $blockTypeFields) ? $blockTypeFields[$blockTypeFieldHandle] : new FieldModel();
         $schematicFieldModel = $fieldFactory->build($blockTypeFieldDef['type']);
         $schematicFieldModel->populate($blockTypeFieldDef, $blockTypeField, $blockTypeFieldHandle);
         $newBlockTypeFields[] = $blockTypeField;
     }
     $blockType->setFields($newBlockTypeFields);
 }
 /**
  * @return array
  */
 protected function defineAttributes()
 {
     return array_merge(parent::defineAttributes(), ['id' => AttributeType::Number, 'userId' => AttributeType::Number, 'email' => AttributeType::String, 'lastUsedBillingAddressId' => AttributeType::Number, 'lastUsedShippingAddressId' => AttributeType::Number]);
 }
 public function __construct($attributes = null)
 {
     // generate unique hash
     $this->hash = md5(uniqid(mt_rand(), true));
     parent::__construct($attributes);
 }
Ejemplo n.º 6
0
 /**
  * @param string     $attribute
  * @param bool|false $flattenValue
  * @param array      $default
  *
  * @return array
  */
 public function getAttribute($attribute, $flattenValue = false, $default = [])
 {
     $attribute = parent::getAttribute($attribute, $flattenValue);
     return !is_null($attribute) ? $attribute : $default;
 }