I
I
Igor2020-11-10 18:26:56
symfony
Igor, 2020-11-10 18:26:56

Self-diagnosis of CRM system?

I welcome colleagues.

I am a member of the CRM system development team.
The complexity grows in proportion to the number of Wishlist.
In addition to bugs, the project has data that depends on other data.

For example.
A project that has certain statuses may not have these statuses.
For example, if there are no statuses, then you need to prohibit a number of actions on the front.
That is, the user can continue to work, but a number of functions are not available.

And that doesn't mean it's a bug.
In fact, this is one of the requirements.

But the user must know for what reason these functions are not available to him.

I thought that you can create some special method to determine the data dependency and issue a list of what needs to be done and for what reason these functions are not available.

Would love to hear advice on this.

Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
BoShurik, 2020-11-10
@BoShurik

I did something similar, it turned out like this:

namespace App\Doctor;

use App\Doctor\Check\CheckInterface;

final class Doctor
{
    /**
     * @var CheckInterface[]
     */
    private iterable $checks;

    public function __construct(iterable $checks)
    {
        $this->checks = $checks;
    }

    /**
     * @return Violation[]|array
     */
    public function check(): array
    {
        $violations = [];
        foreach ($this->checks as $check) {
            $violations[$check->feature()] = array_merge($violations[$check->feature()] ?? [], $check->violations());
        }

        return $violations;
    }
}

namespace App\Doctor\Check;

use App\Doctor\Violation;

interface CheckInterface
{
    public function feature(): string;

    /**
     * @return Violation[]
     */
    public function violations(): array;
}

services:
    _instanceof:
        App\Doctor\Check\CheckInterface:
            tags:
                - { name: app.doctor.check }

    App\Doctor\Doctor:
        arguments:
            $checks: !tagged app.doctor.check

public function doctorAction(): JsonResponse
{
    return $this->json($this->doctor->check());
}

{
    "foo": [], // Ok
    "bar": [
        { "message": "Отсутствуют статусы", "treatment": "Добавьте статусы" }
    ]
}

As an option, you can group checks by features so as not to check everything when you need information on a specific feature, but for this you will need to use CompilerPass

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question