Skip to content

Commit

Permalink
first test
Browse files Browse the repository at this point in the history
  • Loading branch information
Praesidiarius committed Feb 7, 2020
0 parents commit cf8a185
Show file tree
Hide file tree
Showing 9 changed files with 268 additions and 0 deletions.
27 changes: 27 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2019-2020, Verein onePlace
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

- Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

- Neither the name of Verein onePlace nor the names of its contributors may
be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 changes: 53 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "oneplace/oneplace-contact-address",
"description": "onePlace Contact Address Plugin. Multiple Addresses for Contacts",
"type": "oneplace-plugin",
"version": "1.0.0",
"license": "BSD-3-Clause",
"keywords": [
"laminas",
"mvc",
"oneplace-module",
"oneplace",
"skeleton",
"framework"
],
"require-dev": {
"phpunit/phpunit": "^8",
"laminas/laminas-test": "^3.3.0",
"php-coveralls/php-coveralls": "^2.2"
},
"require": {
"php": "^7.1",
"oneplace/oneplace-contact": "^1.0.6"
},
"autoload": {
"psr-4": {
"OnePlace\\Contact\\Address\\": "src/"
}
},
"autoload-dev": {
"psr-4": {

}
},
"scripts": {
"cs-check": "phpcs",
"cs-fix": "phpcbf",
"development-disable": "laminas-development-mode disable",
"development-enable": "laminas-development-mode enable",
"development-status": "laminas-development-mode status",
"post-create-project-cmd": [
"@development-enable",
"php -r '$file = file_get_contents(\".gitignore\"); $file = str_replace(\"composer.lock\", \"\", $file); file_put_contents(\".gitignore\", $file);'"
],
"serve": "php -S 0.0.0.0:8080 -t public",
"test": "phpunit --colors=always",
"test-coverage": "phpunit --colors=always --coverage-clover clover.xml"
},
"extra": {
"zf": {
"module": "OnePlace\\Contact\\Address"
}
}
}
23 changes: 23 additions & 0 deletions config/module.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
/**
* module.config.php - Address Config
*
* Main Config File for Contact Address Plugin
*
* @category Config
* @package Contact\Address
* @author Verein onePlace
* @copyright (C) 2020 Verein onePlace <[email protected]>
* @license https://opensource.org/licenses/BSD-3-Clause
* @version 1.0.0
* @since 1.0.0
*/

namespace OnePlace\Contact\Address;

use Laminas\Router\Http\Literal;
use Laminas\Router\Http\Segment;
use Laminas\ServiceManager\Factory\InvokableFactory;

return [
];
11 changes: 11 additions & 0 deletions data/install.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--
-- Add new tab
--
INSERT INTO `core_form_tab` (`Tab_ID`, `form`, `title`, `subtitle`, `icon`, `counter`, `sort_id`, `filter_check`, `filter_value`) VALUES
('contact-address', 'contact-single', 'Address', 'Delivery & Billing', 'fas fa-home', '', '1', '', '');

--
-- Add new partial
--
INSERT INTO `core_form_field` (`Field_ID`, `type`, `label`, `fieldkey`, `tab`, `form`, `class`, `url_view`, `url_list`, `show_widget_left`, `allow_clear`, `readonly`, `tbl_cached_name`, `tbl_class`, `tbl_permission`) VALUES
(NULL, 'partial', 'Address', 'contact_address', 'contact-address', 'contact-single', 'col-md-12', '', '', '0', '1', '0', '', '', '');
67 changes: 67 additions & 0 deletions src/Controller/AddressController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/**
* AddressController.php - Main Controller
*
* Main Controller for Contact Address Plugin
*
* @category Controller
* @package Contact\Address
* @author Verein onePlace
* @copyright (C) 2020 Verein onePlace <[email protected]>
* @license https://opensource.org/licenses/BSD-3-Clause
* @version 1.0.0
* @since 1.0.0
*/

declare(strict_types=1);

namespace OnePlace\Contact\Address\Controller;

use Application\Controller\CoreEntityController;
use Application\Model\CoreEntityModel;
use OnePlace\Contact\Model\Contact;
use OnePlace\Contact\Model\ContactTable;
use Laminas\View\Model\ViewModel;
use Laminas\Db\Adapter\AdapterInterface;

class AddressController extends CoreEntityController {
/**
* Contact Table Object
*
* @since 1.0.0
*/
protected $oTableGateway;

/**
* ContactController constructor.
*
* @param AdapterInterface $oDbAdapter
* @param ContactTable $oTableGateway
* @since 1.0.0
*/
public function __construct(AdapterInterface $oDbAdapter,ContactTable $oTableGateway,$oServiceManager) {
$this->oTableGateway = $oTableGateway;
$this->sSingleForm = 'contact-single';
parent::__construct($oDbAdapter,$oTableGateway,$oServiceManager);

if($oTableGateway) {
# Attach TableGateway to Entity Models
if(!isset(CoreEntityModel::$aEntityTables[$this->sSingleForm])) {
CoreEntityModel::$aEntityTables[$this->sSingleForm] = $oTableGateway;
}
}
}

/**
* Save Address and attach it to contact
*
* @param $oContact saved Contact
* @param $aFormData raw Form Data
* @param $sState state of saving
* @return bool true or false
* @since 1.0.0
*/
public function attachAddressToContact($oContact,$aFormData,$sState) {
return false;
}
}
78 changes: 78 additions & 0 deletions src/Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/**
* Module.php - Module Class
*
* Module Class File for Contact Address Plugin
*
* @category Config
* @package Contact\Address
* @author Verein onePlace
* @copyright (C) 2020 Verein onePlace <[email protected]>
* @license https://opensource.org/licenses/BSD-3-Clause
* @version 1.0.0
* @since 1.0.0
*/

namespace OnePlace\Contact\Address;

use Application\Controller\CoreEntityController;
use Laminas\Mvc\MvcEvent;
use Laminas\EventManager\EventInterface as Event;
use Laminas\ModuleManager\ModuleManager;
use Laminas\Db\Adapter\AdapterInterface;
use OnePlace\Contact\Address\Controller\AddressController;
use OnePlace\Contact\Model\ContactTable;

class Module {
/**
* Module Version
*
* @since 1.0.0
*/
const VERSION = '1.0.0';

/**
* Load module config file
*
* @since 1.0.0
* @return array
*/
public function getConfig() : array {
return include __DIR__ . '/../config/module.config.php';
}

public function onBootstrap(Event $e)
{
// This method is called once the MVC bootstrapping is complete
$application = $e->getApplication();
$container = $application->getServiceManager();
$oDbAdapter = $container->get(AdapterInterface::class);
$tableGateway = $container->get(ContactTable::class);

# Register Filter Plugin Hook
CoreEntityController::addHook('contact-add-after-save',(object)['sFunction'=>'attachAddressToContact','oItem'=>new AddressController($oDbAdapter,$tableGateway,$container)]);
}

/**
* Load Controllers
*/
public function getControllerConfig() : array {
return [
'factories' => [
# Plugin Example Controller
Controller\AddressController::class => function($container) {
$oDbAdapter = $container->get(AdapterInterface::class);
$tableGateway = $container->get(ContactTable::class);

# hook start
# hook end
return new Controller\AddressController(
$oDbAdapter,
$tableGateway,
$container
);
},
],
];
}
}
3 changes: 3 additions & 0 deletions view/partial/contact_address-add.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
?>
<h2>Add Address</h2>
3 changes: 3 additions & 0 deletions view/partial/contact_address-edit.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
?>
<h2>Edit Address</h2>
3 changes: 3 additions & 0 deletions view/partial/contact_address-view.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
?>
<h2>View Address</h2>

0 comments on commit cf8a185

Please sign in to comment.