Merge pull request #926 from openclassify/dia

#3025 Making the announcement status flexible.
This commit is contained in:
spektra2147 2021-01-26 10:32:29 +03:00 committed by GitHub
commit 7e93deea32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 329 additions and 7 deletions

View File

@ -0,0 +1,43 @@
<?php namespace Visiosoft\AdvsModule\Http\Controller\Admin;
use Visiosoft\AdvsModule\Status\Form\StatusFormBuilder;
use Visiosoft\AdvsModule\Status\Table\StatusTableBuilder;
use Anomaly\Streams\Platform\Http\Controller\AdminController;
class StatusController extends AdminController
{
/**
* Display an index of existing entries.
*
* @param StatusTableBuilder $table
* @return \Symfony\Component\HttpFoundation\Response
*/
public function index(StatusTableBuilder $table)
{
return $table->render();
}
/**
* Create a new entry.
*
* @param StatusFormBuilder $form
* @return \Symfony\Component\HttpFoundation\Response
*/
public function create(StatusFormBuilder $form)
{
return $form->render();
}
/**
* Edit an existing entry.
*
* @param StatusFormBuilder $form
* @param $id
* @return \Symfony\Component\HttpFoundation\Response
*/
public function edit(StatusFormBuilder $form, $id)
{
return $form->render($id);
}
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\AdvsModule\Status\Contract;
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
interface StatusInterface extends EntryInterface
{
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\AdvsModule\Status\Contract;
use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface;
interface StatusRepositoryInterface extends EntryRepositoryInterface
{
}

View File

@ -0,0 +1,66 @@
<?php namespace Visiosoft\AdvsModule\Status\Form;
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
class StatusFormBuilder extends FormBuilder
{
/**
* The form fields.
*
* @var array|string
*/
protected $fields = [];
/**
* Additional validation rules.
*
* @var array|string
*/
protected $rules = [];
/**
* Fields to skip.
*
* @var array|string
*/
protected $skips = [];
/**
* The form actions.
*
* @var array|string
*/
protected $actions = [];
/**
* The form buttons.
*
* @var array|string
*/
protected $buttons = [
'cancel',
];
/**
* The form options.
*
* @var array
*/
protected $options = [];
/**
* The form sections.
*
* @var array
*/
protected $sections = [];
/**
* The form assets.
*
* @var array
*/
protected $assets = [];
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\AdvsModule\Status;
use Anomaly\Streams\Platform\Entry\EntryCollection;
class StatusCollection extends EntryCollection
{
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\AdvsModule\Status;
use Anomaly\Streams\Platform\Entry\EntryCriteria;
class StatusCriteria extends EntryCriteria
{
}

View File

@ -0,0 +1,9 @@
<?php namespace Visiosoft\AdvsModule\Status;
use Visiosoft\AdvsModule\Status\Contract\StatusInterface;
use Anomaly\Streams\Platform\Model\Advs\AdvsStatusEntryModel;
class StatusModel extends AdvsStatusEntryModel implements StatusInterface
{
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\AdvsModule\Status;
use Anomaly\Streams\Platform\Entry\EntryObserver;
class StatusObserver extends EntryObserver
{
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\AdvsModule\Status;
use Anomaly\Streams\Platform\Entry\EntryPresenter;
class StatusPresenter extends EntryPresenter
{
}

View File

@ -0,0 +1,25 @@
<?php namespace Visiosoft\AdvsModule\Status;
use Visiosoft\AdvsModule\Status\Contract\StatusRepositoryInterface;
use Anomaly\Streams\Platform\Entry\EntryRepository;
class StatusRepository extends EntryRepository implements StatusRepositoryInterface
{
/**
* The entry model.
*
* @var StatusModel
*/
protected $model;
/**
* Create a new StatusRepository instance.
*
* @param StatusModel $model
*/
public function __construct(StatusModel $model)
{
$this->model = $model;
}
}

View File

@ -0,0 +1,8 @@
<?php namespace Visiosoft\AdvsModule\Status;
use Anomaly\Streams\Platform\Entry\EntryRouter;
class StatusRouter extends EntryRouter
{
}

View File

@ -0,0 +1,15 @@
<?php namespace Visiosoft\AdvsModule\Status;
use Anomaly\Streams\Platform\Database\Seeder\Seeder;
class StatusSeeder extends Seeder
{
/**
* Run the seeder.
*/
public function run()
{
//
}
}

View File

@ -0,0 +1,63 @@
<?php namespace Visiosoft\AdvsModule\Status\Table;
use Anomaly\Streams\Platform\Ui\Table\TableBuilder;
class StatusTableBuilder extends TableBuilder
{
/**
* The table views.
*
* @var array|string
*/
protected $views = [];
/**
* The table filters.
*
* @var array|string
*/
protected $filters = [];
/**
* The table columns.
*
* @var array|string
*/
protected $columns = [
'name',
];
/**
* The table buttons.
*
* @var array|string
*/
protected $buttons = [
'edit'
];
/**
* The table actions.
*
* @var array|string
*/
protected $actions = [
'delete'
];
/**
* The table options.
*
* @var array
*/
protected $options = [];
/**
* The table assets.
*
* @var array
*/
protected $assets = [];
}

View File

@ -6,20 +6,13 @@ use Anomaly\UsersModule\User\Authenticator\Contract\AuthenticatorExtensionInterf
use Anomaly\UsersModule\User\Contract\UserInterface;
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
use Anomaly\UsersModule\User\Event\UserWasLoggedIn;
use Anomaly\UsersModule\User\User;
use Anomaly\UsersModule\User\UserPassword;
use http\Env\Response;
use Visiosoft\AdvsModule\Adv\AdvModel;
use Visiosoft\AdvsModule\Http\Controller\AdvsController;
use Visiosoft\CartsModule\Saleitem\Command\ProcessSaleitem;
use Visiosoft\CartsModule\Saleitem\SaleitemModel;
use Visiosoft\CloudsiteModule\Site\Event\CreateSite;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Container\Container;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Redirect;
use Visiosoft\CloudsiteModule\Site\SiteModel;
use Visiosoft\ProfileModule\Profile\ProfileRepository;

View File

@ -1,11 +1,23 @@
<?php namespace Visiosoft\ProfileModule\Profile\Profile;
use Anomaly\Streams\Platform\Addon\Extension\ExtensionCollection;
use Anomaly\Streams\Platform\Message\MessageBag;
use Anomaly\UsersModule\User\Authenticator\Contract\AuthenticatorExtensionInterface;
use Anomaly\UsersModule\User\Contract\UserInterface;
use Anomaly\UsersModule\User\UserModel;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Redirect;
use Visiosoft\ProfileModule\Events\UserUpdated;
class ProfileFormHandler
{
protected $extensions;
public function __construct(ExtensionCollection $extensions)
{
$this->extensions = $extensions;
}
public function handle(
ProfileFormBuilder $builder,
MessageBag $messages,
@ -27,6 +39,11 @@ class ProfileFormHandler
'google_address' => $builder->getPostValue('google_address') ?: null,
];
if (($valid = $this->validate($parameters)) !== true) {
$messages->error($valid['msg']);
return;
}
if (setting_value('visiosoft.module.profile::show_education_profession')) {
$parameters = array_merge($parameters, [
'education' => $builder->getPostValue('education'),
@ -70,4 +87,21 @@ class ProfileFormHandler
}
return $changes;
}
public function validate(array $fields)
{
$validators = $this->extensions
->search('visiosoft.module.profile::validation.*')
->enabled();
foreach ($validators as $validator) {
$valid = $validator->validate($fields);
if ($valid['error']) {
return $valid;
}
}
return true;
}
}

View File

@ -0,0 +1,6 @@
<?php namespace Visiosoft\ProfileModule\Profile\Validator\Contract;
interface ValidatorExtensionInterface
{
public function validate(array $fields);
}

View File

@ -0,0 +1,12 @@
<?php namespace Visiosoft\ProfileModule\Profile\Validator;
use Anomaly\Streams\Platform\Addon\Extension\Extension;
use Visiosoft\ProfileModule\Profile\Validator\Contract\ValidatorExtensionInterface;
class ValidatorExtension extends Extension implements ValidatorExtensionInterface
{
public function validate(array $fields)
{
return null;
}
}