Refactor project structure
This commit is contained in:
32
core/src/FieldNames/Admin/Api/FieldNamesAdminManager.php
Normal file
32
core/src/FieldNames/Admin/Api/FieldNamesAdminManager.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Thilina
|
||||
* Date: 8/19/17
|
||||
* Time: 12:29 PM
|
||||
*/
|
||||
|
||||
namespace FieldNames\Admin\Api;
|
||||
|
||||
use Classes\AbstractModuleManager;
|
||||
|
||||
class FieldNamesAdminManager extends AbstractModuleManager
|
||||
{
|
||||
public function initializeUserClasses()
|
||||
{
|
||||
}
|
||||
|
||||
public function initializeFieldMappings()
|
||||
{
|
||||
}
|
||||
|
||||
public function initializeDatabaseErrorMappings()
|
||||
{
|
||||
}
|
||||
|
||||
public function setupModuleClassDefinitions()
|
||||
{
|
||||
$this->addModelClass('FieldNameMapping');
|
||||
$this->addModelClass('CustomField');
|
||||
}
|
||||
}
|
||||
64
core/src/FieldNames/Common/Model/CustomField.php
Normal file
64
core/src/FieldNames/Common/Model/CustomField.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Thilina
|
||||
* Date: 8/19/17
|
||||
* Time: 12:27 PM
|
||||
*/
|
||||
|
||||
namespace FieldNames\Common\Model;
|
||||
|
||||
use Classes\BaseService;
|
||||
use Classes\IceResponse;
|
||||
use Model\BaseModel;
|
||||
|
||||
class CustomField extends BaseModel
|
||||
{
|
||||
public $table = 'CustomFields';
|
||||
|
||||
public function getAdminAccess()
|
||||
{
|
||||
return array("get","element","save","delete");
|
||||
}
|
||||
|
||||
public function getUserAccess()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getAnonymousAccess()
|
||||
{
|
||||
return array("get","element");
|
||||
}
|
||||
|
||||
public function validateSave($obj)
|
||||
{
|
||||
$type = BaseService::getInstance()->getFullQualifiedModelClassName($obj->type);
|
||||
$baseObject = new $type();
|
||||
$fields = $baseObject->getObjectKeys();
|
||||
if (isset($fields[$obj->name])) {
|
||||
return new IceResponse(IceResponse::ERROR, "Column name already exists by default");
|
||||
}
|
||||
|
||||
$cf = new CustomField();
|
||||
if (empty($obj->id)) {
|
||||
$cf->Load("type = ? and name = ?", array($obj->type, $obj->name));
|
||||
if ($cf->name == $obj->name) {
|
||||
return new IceResponse(
|
||||
IceResponse::ERROR,
|
||||
"Another custom field with same name has already been added"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$cf->Load("type = ? and name = ? and id <> ?", array($obj->type, $obj->name, $obj->id));
|
||||
if ($cf->name == $obj->name) {
|
||||
return new IceResponse(
|
||||
IceResponse::ERROR,
|
||||
"Another custom field with same name has already been added"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return new IceResponse(IceResponse::SUCCESS, "");
|
||||
}
|
||||
}
|
||||
31
core/src/FieldNames/Common/Model/FieldNameMapping.php
Normal file
31
core/src/FieldNames/Common/Model/FieldNameMapping.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Thilina
|
||||
* Date: 8/19/17
|
||||
* Time: 12:28 PM
|
||||
*/
|
||||
|
||||
namespace FieldNames\Common\Model;
|
||||
|
||||
use Model\BaseModel;
|
||||
|
||||
class FieldNameMapping extends BaseModel
|
||||
{
|
||||
public $table = 'FieldNameMappings';
|
||||
|
||||
public function getAdminAccess()
|
||||
{
|
||||
return array("get","element","save","delete");
|
||||
}
|
||||
|
||||
public function getUserAccess()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getAnonymousAccess()
|
||||
{
|
||||
return array("get","element");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user