The trait Idable provides a method equalsId that in turn relies on the
method getId(). If this method does not exist on a class mixing in this
trait, the method will fail.
Adding the getId() as an abstract method to the trait will make sure it
is available.
The trait Idable provides a method equalsId that in turn relies on the
method getId(). If this method does not exist on a class mixing in this
trait, the method will fail.
Adding the getId() as an abstract method to the trait will make sure it
is available.
Loading history...
37
}
38
39
/**
40
* Get image url for given size.
41
*
42
* @param string $name Name of image to get url for.
43
* @param string $size Size of image.
44
*
45
* @return string|null
46
*/
47
public function imageUrl($name, $size = 'medium')
48
{
49
if (!$image = $this->image($name)) {
50
return;
51
}
52
53
return $image->{$size}();
54
}
55
56
/**
57
* Get caption for image.
58
*
59
* @param string $name Name of image to get caption for.
60
*
61
* @return string|null
62
*/
63
public function imageCaption($name)
64
{
65
if (!$image = $this->image($name)) {
66
return;
67
}
68
69
return $image->caption();
70
}
71
72
/**
73
* Get alt for image.
74
*
75
* @param string $name Name of image to get caption for.
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.