Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IMPLEMENTATION OF AN INTERFACE
- INHERIT BY EXTENDING
- ABSTRACT IS BOILERPLATE YOU DEFINE
- plugins extend methods and do not change class itself
- when to use factory:
- retrieve data \model class make new class
- Repositories are part of the Service Contracts (they are implementations of interfaces in Api), this means they are meant as a public interface to other modules.
- Factory Model in Magento 2 hold very limited data.
- On the Other hand, Repository Model contains all data, in case of eav attributes related to customer, products , etc.
- For saving model, always use Repository to save any entity, if factory model is used for saving model, it deletes all non-system eav attributes related to that entity (customer, product, etc.).
- For loading model purpose, Repository are best option to get model using getById() method.
- extends INHERITS
- override same name methods
- dont worry about the other methods if no custom functionality. you can still use parent class methods on said custom class.
- Classes can implement an interface while inheriting from another class at the same time
- Abstract
- When inheriting from an abstract class, all methods marked abstract in the parent's class declaration must be defined by the child;
- A subclass must override abstract methods or otherwise should be 'abstract' themselves.
- Object Interfaces IMPLEMENTS
- allow you to create code which specifies which methods a class must implement, without having to define how these methods are implemented.
- PHP - Interfaces vs. Abstract Classes
- Interface are similar to abstract classes. The difference between interfaces and abstract classes are:
- Interfaces cannot have properties, while abstract classes can
- Like an abstract class, Interface is another way to define abstract type
- All interface methods must be public, while abstract class methods is public or protected
- All methods in an interface are abstract, so they cannot be implemented in code and the abstract keyword is not necessary
- To implement an interface, a class must use the implements keyword.
- New instantiation of a class is an Object
- Variables and functions are called properties and methods respectively in OOP world.
- public: can be accessed anywhere.
- protected: can be accessed by the class and subclasses only.
- private: can be accessed by the class only.
- Static properties can be called without instantiating a new class object
- new class that inherits a parent class is called a SUB CLASS
- A subclass inherits all properties and methods from it's super (parent) class except for private ones.
- Parent class constructor are not implicitly called if the child class defines them as well. a call to parent::__construct() within the child constructor is required.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement